我真的很困惑为什么会发生在我身上:
Python 3.7.1 (default, Nov 5 2018, 14:07:04)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.4.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: 10**3.5
ValueError: could not convert string to float: 3.5
有人能发光吗?如您所见,这是一个简单的输入,我认为它是一个浮点文字。
我试过消除ipython的复杂性,并以隔离模式运行,但仍然:
python3 -I -c "float('3.5')"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ValueError: could not convert string to float: '3.5'
我的蟒蛇3.7断了,我的理解断了,还是我在看什么?
我通过将显示的代码放入一个文件中并进行十六进制转储来排除编码问题。它是干净的ASCII码,就像它应该的那样,带有
0x2e
一个点,和一个
0x0a
作为行尾:
xxd testfile.py
00000000: 332e 350a 3.5.
python3 -I testfile.py
ValueError: could not convert string to float: 3.5
操作系统:使用16 GB RAM的x86_64上的Fedora29。