【发布时间】:2018-06-12 19:34:09
【问题描述】:
我正在编写一个文本文件,其中包含我使用 python 分析的一些数据。我遇到了一些错误消息。下面是我的代码。
sixteen=0.1
fifteen=0.3
fourteen=-.4
fourteen_revised=1
thirteen=2
with open('TMV_AVD.txt','w') as f:
f. write('16+',sixteen+'\n','15+', fifteen+'\n','14+',\
fourteen+'\n','14-',fourteen_revised+'\n', '13-', thirteen)
我想要的文本文件如下
16+,0.1
15+,0.3
14+,-.4
14-,1
13-,2
我得到的错误信息如下。
ufunc 'add' did not contain a loop with signature matching types dtype('<U32') dtype('<U32') dtype('<U32').
我以为我理解了with open 功能。您的建议将不胜感激。有什么建议么?
【问题讨论】:
-
我收到
TypeError: unsupported operand type(s) for +: 'float' and 'str'。 -
使用“your_string”.format()
-
请在问题正文中发布您遇到的错误的全文。
标签: python python-3.x with-statement