問題:
Scenario: An interactive CLI Python program, that is in need for a password. 場景:一個交互式CLI Python程序,需要密碼。 That means also, there's no GUI solution possible. 這也意味着不可能有GUI解決方案。
In bash I could get a password read in without re-prompting it on screen via 在bash中,我可以讀取密碼而無需通過以下方式在屏幕上重新提示
read -s
Is there something similar for Python? Python有類似的東西嗎? Ie, 即
password = raw_input('Password: ', dont_print_statement_back_to_screen)
Alternative: Replace the typed characters with '*' before sending them back to screen (aka browser' style). 替代方法:將鍵入的字符替換爲“ *”,然後再將其發送回屏幕(又稱瀏覽器樣式)。
解決方案:
參考一: https://en.stackoom.com/question/7OJE參考二: https://stackoom.com/question/7OJE