我正在制作一个应该加密您传入的密码的程序。但是,每当我运行它时,它都会引发错误:
Password = float(input('Enter Password: '))
ValueError: could not convert string to float: 'Banana' (我为这个测试选择的词)
这是我的代码:
#Macchiat0
#10 May 2016
#This program will encrypt and decrypt user passwords.
#init
encryptionlist = (('a','q'),
('b','w'),
('c','e'),
('d','r'),
('e','t'),
('f','y'),
('g','u'),
('h','i'),
('i','o'),
('j','p'),
('k','a'),
('l','s'),
('m','d'),
('n','f'),
('o','g'),
('p','h'),
('q','j'),
('r','k'),
('s','l'),
('t','z'),
('u','x'),
('v','c'),
('w','v'),
('x','b'),
('y','n'),
('z','m'))
print('This program will encrypt and decrypt user passwords')
#Program Menu
ans = True
while True:
print('1. Enter 1 to encrypt a password: ')
print('2. Enter 2 to decrypt a password: ')
print('3. Exit/Quit')
ans = input('What do you want to do? ')
if ans == "1":
print("\n Enter 1 to encrypt a password: ")
Password = float(input('Enter Password: '))
print('Your new encryptid password is:', Password)
if ans == "2":
print("\n Enter 2 to decrypt a password: ")
Password = float(input('Enter Password: '))
print('Your new decrypted password is:', Password)
elif ans == "3":
print("\n Goodbye")
break
else:
print("\n Not Valid Choice Try Again")