我需要Python 2.7中的数据验证问题的帮助,它做我想要的不接受字符串,但它不接受整数,因为它应该做.
def GetKeyForCaesarCipher():
while True:
key =(raw_input('Enter the amount that shifts the plaintext alphabet to the ciphertext alphabet: '))
try:
i=int(key)
break
except ValueError:
print ('Error, please enter an integer')
return key
Run Code Online (Sandbox Code Playgroud)