【发布时间】:2018-05-03 04:40:46
【问题描述】:
我一直在开发一个旨在加密用户输入的消息的程序。加密过程完成后,我希望程序提示用户选择是否要加密另一条消息。
option2 = int(input('Would you like to encrypt another message? (Yes = 1 and No = 2)'))
while option2 not in [1, 2]:
print 'Please type 1 or 2.'
option2 = int(raw_input())
while True:
option2 = int(raw_input())
if option2 == 1:
option1 = int(input('Which encryption method would you like to use? 1 = Across (NOPQ ...) and 2 = Backwards (ZYXW ...)'))
while True:
option2 = int(raw_input())
if option2 == 2:
break
这段代码导致
"ValueError: int() 以 10 为底的无效文字:''"
我从未遇到过的错误。我该如何解决这个问题?
【问题讨论】:
-
这意味着用户没有输入任何内容。如果您确保用户键入某些内容,它将起作用。你也可以使用 try 和 except
标签: python int literals base valueerror