我正在使用 Python 并定义了一个名为“_headers”的变量,如下所示
_headers = ('id',
'recipient_address_1',
'recipient_address_2',
'recipient_address_3',
'recipient_address_4',
'recipient_address_5',
'recipient_address_6',
'recipient_postcode',
)
为了将其写入输出文件,我编写了以下语句,但它抛出错误“AttributeError:'str'对象没有属性'write'”
with open(outfile, 'w') as f:
outfile.write(self._headers)
print done
请帮忙