>>> w
['Parts-of-speech', 'disambiguation', 'techniques', '(', 'taggers', ')',
'are', 'often', 'used', 'to', 'eliminate', '(', 'or', 'substantially',
'reduce', ')', 'the', 'parts-of-speech', 'ambiguitiy', 'prior', 'to',
'parsing.', 'The', 'taggers', 'are', 'all', 'local', 'in', 'the', 'sense',
'that', 'they', 'use', 'information', 'from', 'a', 'limited', 'context',
'in', 'deciding', 'which', 'tag', '(', 's', ')', 'to', 'choose', 'for',
'each', 'word.', 'As', 'is', 'well', 'known', ',', 'these', 'taggers',
'are', 'quite', 'successful', '.']
>>> q=open("D:\unieng.txt","w")
>>> q.write(w)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: argument 1 must be string or read-only character buffer, not list
Tags:
您需要使用join将列表连接到字符串中。更改写入
到
使用^{} 方法编写内容。
文件.writelines(序列)
注意:
writelines()
不添加行分隔符。w
是一个列表,错误说明文件对象的write方法不接受list。您可以将w转换为字符串并按如下方式编写:
然后你可以打电话给:
相关问题 更多 >
编程相关推荐