您的位置:首页 > 编程语言 > Python开发

python getpass模块:隐藏不显示输入的密码

2016-08-08 21:59 405 查看

不知道为什么,本机测试必须要在debug模式下才正常运行。。

import getpass                                  #用于隐藏用户输入的字符串,常用来接收密码

def checkuser(user,passwd):
if user == 'chenhang' and passwd == '123456':
return True
else:
return False

if __name__ == "__main__":
userr = input('Input the user:')
passwdd = getpass.getpass('Input the passwd:')

if checkuser(userr,passwdd):
print('OK!')
else:
print('ERROR!')

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: