Python使用eval强制转换字符串为字典时报错:File "<string>", line 1, in <module> NameError: name 'nan' is not defined
2014-08-28 15:58
1971 查看
文本中保存的内容为:
用eval转换为字符串时报错:
解决:
参考资料:
Python中,用eval强制将字符串转换为字典变量时候出错:NameError: name ‘null’ is not defined
{ 'QQQ': [0.067, 0.167, 0.2, 0.033, 0.233, 0.267, 0.1, 0.133], 'TTT': [0.5, 0.375, 0.25, 0.3, 0.6, 0.333, 0.857, 0.636, 0.667, 0.556] }
用eval转换为字符串时报错:
File "test.py", line 43, in d1 data = eval(infile.readline()) File "<string>", line 1, in <module> NameError: name 'nan' is not defined
解决:
globals = { 'nan': 0 } # ----------- data = eval(infile.readline(), globals)
参考资料:
Python中,用eval强制将字符串转换为字典变量时候出错:NameError: name ‘null’ is not defined
相关文章推荐
- [python]用eval强制将字符串转换为字典变量时候出错:NameError: name 'null' is not defined[python]用eval函数 字符串转dict
- Python中,用eval强制将字符串转换为字典变量时候出错:NameError: name 'null' is not defined
- Python中用eval将字符串转换为字典时候出错:NameError: name ‘null’ is not defined的解决方法
- python:File "<string>", line 1, in <module>
- Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named
- python 2.6 mycli安装,File "/usr/bin/mycli", line 7, in <module>
- CDH报错:Traceback (most recent call last): File "<string>", line 1, in <module> File "<string>"
- Python 解决 :NameError: name 'reload' is not defined 问题
- python NameError: name 'raw_input' is not defined
- Python使用Tkinter错误,NameError: global name 'TOP' is not defined
- File "scripts/rule_bison.py", line 75, in <module>
- The MagicAjax HttpModule is not included in web.config. Add [<httpModules><add name="MagicAjax" type
- Centos 7.0 execute yum update ——File "/usr/libexec/urlgrabber-ext-down", line 75, in <module>
- python {File "<stdin>", line 1} error
- python2.7以下出 NameError: global name 'FileNotFoundError' is not defined的解决方案
- The MagicAjax HttpModule is not included in web.config. Add [<httpModules><add name="MagicAjax" type="MagicAjax.MagicAja
- python eval方法转换字符串到字典类型时NameError
- python安装setuptools报错Traceback (most recent call last): File "setup.py", line 11, in <module> i
- Python 解决 :NameError: name 'reload' is not defined 问题
- python之NameError: name 'raw_input' is not defined