0
這究竟是爲什麼?:爲什麼Python爲int()看起來有效的字符串引發ValueError?
>>> int('20', 3)
6
>>> int('8', 3)
Traceback (most recent call last):
File "<pyshell#9>", line 1, in <module>
int('8', 3)
ValueError: invalid literal for int() with base 3: '8'
是的,我已經看到了這個帖子:ValueError: invalid literal for int() with base 10: ''
但 '8' 沒有任何小數。它也沒有任何空格。爲什麼這不起作用?當然8可能代表基數3.
哦,男人,我覺得愚蠢。謝謝。 – user124384