Python:Int()Base 10的无效文字

Python:Int()Base 10的无效文字,第1张

Python:Int()Base 10的无效文字

好吧,无论您输入什么内容,实际上都不是以10为底的数字。这包括非数字字符或空格的任何内容。所以不要输入。:-)

例子:

>>> int('04.9')Traceback (most recent call last):  File "<stdin>", line 1, in <module>ValueError: invalid literal for int() with base 10: '04.9'>>> int('4-')Traceback (most recent call last):  File "<stdin>", line 1, in <module>ValueError: invalid literal for int() with base 10: '4-'>>> int("Jack")Traceback (most recent call last):  File "<stdin>", line 1, in <module>ValueError: invalid literal for int() with base 10: 'Jack'

更新:是的,您键入了“#”。这不是有效数字。



欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5106413.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-17
下一篇 2022-11-17

发表评论

登录后才能评论

评论列表(0条)

保存