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


不知道为什么,本机测试必须要在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!')

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM