Python3 实现用户登陆,输入三次密码
生活随笔
收集整理的這篇文章主要介紹了
Python3 实现用户登陆,输入三次密码
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
不加注釋版
#/usr/bin/python3 import readline user = "seven" passwd = "123" username = input("please the enter user:") for i in range(3):password = input("please the enter password:")if password.isdigit():password = int(password)if username == user and password == passwd:print("logon successfull")breakelse:print("logon failed")else:print("logon failed")加注釋版
#/usr/bin/python3 import readline#導入readline模塊,否則無法移動光標和刪除 user = "seven" passwd = "123"#定義賬號密碼 username = input("please the enter user:")#提示用戶輸入賬號信息 for i in range(3):#如果登陸失敗允許重復輸入三次password = input("please the enter password")#提示用戶輸入密碼if password.isdigit():#判斷輸入的是否是數字 是則進行下一步 否則返回失敗password = int(password)#賦值定義密碼等于輸入密碼if username == user and password == passwd:#判斷賬號和密碼是否一致print("logon successfull")#Truebreakelse:print("logon failed")#Falseelse:print("logon failed")#不是數字則返回False初接觸Python 歡迎大家多多提意見
轉載于:https://www.cnblogs.com/Gnnnny/p/7998035.html
總結
以上是生活随笔為你收集整理的Python3 实现用户登陆,输入三次密码的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 根据多个点使用canvas贝赛尔曲线画一
- 下一篇: python socketserver实