這個問題在這里已經有了答案: 如何將輸入讀取為數字? (10 個回答) 1 小時前關閉。
Python 不斷向我發送錯誤的密碼,我知道為什么,任何人都有任何想法,順便說一句,這是我第一次使用 python :)
i=3
def pw():
global i
if i==3:
p=1312
print('Input the password:')
print('[You have 3 tries to guess the password!]')
pu = input()
if pu == p:
print('Access Granted!')
elif pu != p:
print('Access Denided!')
print('Passwords dont match!')
i-=1
pw()
elif i==2:
p=1312
print('------------------------------------------------------------------------------------------------------------------------')
print('Input the password:')
print('[You have 2 tries to guess the password!]')
pu = input()
if pu == p:
print('Access Granted!')
elif pu != p:
print('Access Denided!')
print('Passwords dont match!')
i-=1
pw()
elif i==1:
p=1312
print('------------------------------------------------------------------------------------------------------------------------')
print('Input the password:')
print('[You have 1 try to guess the password!]')
print('NOTE: If you dont guess the password the computer will shutdown!')
pu = input()
if pu == p:
print('Access Granted')
elif pu != p:
print('Access Denided!')
print('Passwords dont match!')
print('------------------------------------------------------------------------------------------------------------------------')
i-=1
pw()
print('Welcome to Your first project.')
print('Please input wanted paramaters!')
print('Please input your name and surname:')
Name = input()
print('Nice to meet you ' Name)
pw()
Python 不斷向我發送錯誤的密碼,我知道為什么,任何人都有任何想法,順便說一句,這是我第一次使用 python :)
uj5u.com熱心網友回復:
p是數字型別,pu而是字串型別。你比較一個字串和一個數字,所以你得到False. 嘗試替換p=1312為p="1312".
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/425877.html
標籤:Python python-3.x
上一篇:匹配的查詢不存在。在django
