【发布时间】:2016-05-16 20:52:57
【问题描述】:
def check_password(x):
while x != ("admin123"):
x = input("incorrect password \ntry again:")
return x
password = input("please type the password: ")
password = check_password(password)
print ("correct password")
出于安全原因,我尝试在 IDLE 终端中用星号 (*) 替换用户输入的每个字符,因为用户将输入密码。我找到了一些替代方案,例如 getpass() 模块,但 getpass() 不会在终端 IDLE 上为用户显示任何内容来告诉他/她正在输入。因此,我决定寻找替代解决方案而不是 getpass()。
【问题讨论】:
-
@Gary 该解决方案对我不起作用,因为我在 Windows 上使用 IDLE,它显示(没有名为“termios”的模块),所以这不是我问题的解决方案。
-
@Y.Hasan 用谷歌搜索找到了我this。可能会有所帮助。是的,有时这种重复的标记会杀死实际的非重复问题
:-(
标签: python python-3.x passwords