AttributeError: 'tuple' object has no attribute 'writelines'
程序员文章站
2022-05-27 11:51:28
...
new_file = ('./data/es.txt', 'w')
new_file.writelines('date' + lines[3][:-1] + ';DEL' + lines[3][-1])
Traceback (most recent call last):
File "<ipython-input-35-b6e2c5c19dbf>", line 1, in <module>
new_file.writelines('date' + lines[3][:-1] + ';DEL' + lines[3][-1])
AttributeError: 'tuple' object has no attribute 'writelines'
报错的原因:
因为new_file并没有open文件,需改为
new_file = open('./data/es.txt', 'w')
推荐阅读
-
python编程排除163邮箱发送邮件报错(AttributeError: ‘tuple‘ object has no attribute ‘encode‘)
-
python编程排除163邮箱发送邮件报错(AttributeError: ‘tuple‘ object has no attribute ‘encode‘)
-
AttributeError: module ‘community‘ has no attribute ‘best_partition‘ 问题解决方法
-
【python】解决AttributeError: module ‘scipy.misc‘ has no attribute ‘toimage‘问题
-
【Tensorflow】Linux下Tensorflow报错:AttributeError: module ‘tensorflow‘ has no attribute ‘xxxx‘
-
AttributeError: 'module' object has no attribute 'main'
-
AttributeError: module 'sklearn' has no attribute 'linear_model'
-
解决Keras报错AttributeError: 'NoneType' object has no attribute 'inbound_nodes'
-
解决'DataFrame' object has no attribute 'sort'
-
‘MyObject‘ object has no attribute ‘***‘