Python3.7.1:`10**3.5`:无法将字符串转换为浮点:3.5
我真的很困惑为什么这会发生在我身上:Python3.7.1:`10**3.5`:无法将字符串转换为浮点:3.5,python,floating-point,python-3.7,valueerror,Python,Floating Point,Python 3.7,Valueerror,我真的很困惑为什么这会发生在我身上: 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
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'
OS:Fedora 29在一个16 GB内存的x86_64上运行。问题是由于Fedora似乎在没有我的交互的情况下进行glibc更新造成的 GDB的一个扩展程序调查显示libc功能被错误调用
所以我重新启动了。问题似乎解决了。有趣-我想知道复制这个过程需要什么条件?对我来说,这在Python 3.7.1和Ipython 7.1.1上正常工作,没有
ValueError
,当type(10)
和type(3.5)
时会发生什么?导入dis如何;dis.dis('3.5')?我认为,如果不进行指令级GDB会话之类的操作,我们就无法解决这个问题,因为执行堆栈溢出是不实际的。此时最实用的选择可能是重新安装Python,并希望问题消失。(这让我想起AIX上有人在浮点到字符串转换的输出中看到冒号。)@user2357112我已经在GDB中调试了一些东西;结果是:我一定错过了发生在我眼前的glibc
更新。libc函数的调用方式毫无意义。所以,我重新开始。。瞧,它成功了
xxd testfile.py
00000000: 332e 350a 3.5.
python3 -I testfile.py
ValueError: could not convert string to float: 3.5