-1
나는 사용자가 입력 한 메시지를 암호화하기위한 프로그램을 만들고있다. 암호화 프로세스가 끝나면 다른 프로그램을 암호화할지 여부를 묻는 메시지를 프로그램에 표시합니다."ValueError : 기본 10 인 int()에 대한 리터럴이 잘못되었습니다." ' "?
"ValueError: invalid literal for int() with base 10: ''"
에서
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
이 코드의 결과 내가 전에 발생한 적이없는 오류. 이 문제를 어떻게 해결할 수 있습니까? 그 부분은해야
int(input(...
스토어 입력을 문자열
option2 not in ['1', '2']
확인, 그리고 :
이 사용자가 아무것도 입력하지 의미합니다. 사용자가 뭔가를 입력하면 작동 할 것입니다. 또한 시도를 사용할 수도 있습니다. –
https://stackoverflow.com/questions/47381636/confusion-over-invalid-syntax-caused-by-while-statement와 관련 있습니다. – Shadow