这里是我的代码
inputUSer=input('''
Please Select The Mode you want to operate The script AS:
1: You selected-1 \n
2: You selected-2 \n
3: You selected-3\n
4: You selected-4 \n
''')
if inputUSer==1:
print("You selected-1")
elif inputUSer==2:
print("You selected-2")
elif inputUSer== 3:
print("You selected-3")
elif inputUSer== 4:
print("You selected-4")
else :
print("OOPS! Seems like you entered the wrong Input")我检查了所有的压痕,这是正确的。我对蟒蛇和Noob很陌生。请帮帮我..。谢谢..。
发布于 2020-06-06 08:22:25
input()的结果是一个str,它永远不等于1,2,3,4作为它们的ints,您需要转换输入
inputUSer = int(input('''
Please Select The Mode you want to operate The script AS:
1: You selected-1 \n
2: You selected-2 \n
3: You selected-3\n
4: You selected-4 \n
'''))或将所有if更改为比较str。
if inputUSer == '1':发布于 2020-06-06 08:24:19
将输入传递到int()
inputUSer=int(input('''
Please Select The Mode you want to operate The script AS:
1: You selected-1 \n
2: You selected-2 \n
3: You selected-3\n
4: You selected-4 \n
'''))发布于 2020-06-06 08:24:20
input的返回值是一个字符串。您可能希望使用int函数将其转换为整数。或者,您可以更改if条件,将inputUSer与字符串进行比较。
https://stackoverflow.com/questions/62229131
复制相似问题