python 输入0表示输入结束_python输入以0开头的数字

我正在用python编写一个程序。假设它接受一个GTIN编号并放入一个列表中,然后检查它是否有效。程序正常工作,但只要我输入一个以0开头的GTIN编号,就会出现一个“invalid token(,line 1)”错误。我真的需要一个解决方案,因为有些产品的GTIN编号以0开头。在

例如,当我输入一个数字时:96080832

这个程序很好用。在

当我输入一个数字,比如:

^{pr2}$

我得到一个错误:invalid token (, line 1)

指向这条线:inputtedInt = int(input(“Enter the gtin number: “))

整体定义:def chooseOption(inputInt):

while(inputInt > 0 and inputInt < 4):

if(inputInt == 1):

print(“you picked option number 1”)

showOptions()

break

elif(inputInt == 2):

print(” “)

inputtedInt = int(input(“Enter the gtin number: “))

gtin = map(int,str(inputtedInt))

checkValidity(gtin, 2)

print(” “)

showOptions()

break

elif(inputInt == 3):

print(“you picked option number 3”)

showOptions()

break

else:

option = int(input(“Error – enter a number from 1 to 3. : “))

chooseOption(option)

提前谢谢。在

    原文作者:weixin_39824223
    原文地址: https://blog.csdn.net/weixin_39824223/article/details/110628821
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞