如何在python中更改密碼?我試圖更改密碼,但它使用初始密碼。如何在代碼中實現新密碼?如何更改或覆蓋輸入密碼
def password():
pw = input("Enter Password: ")
if pw == initial_pw:
print("Initializing....")
time.sleep(0.5)
else:
print("Access Denied! Wrong Password!")
password()
def Setting():
pw = input("Enter Old Password: ")
if pw == initial_pw:
new_pw = input("Enter New Password: ")
print (new_pw)
print ("Password has been changed.")
else:
print ("Sorry, you have just entered an invalid password.")
Setting()
initial_pw = input("Create New Password: ")
print("Create Successful.")
while True:
password()
print("Press 1 to change password")
choice = int(input("Please choose an option: "))
if choice == 1:
Setting()
何時以及爲什麼要更改它? –
我希望用戶能夠更改密碼以擁有更安全的系統。這個密碼基本上是爲了防止入侵者。 – Newcomer