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