是否可以使用 csv.writer 将数据写入变量而不是文件?
我希望我能做这样的事情:
data = ''
csv.writer(data)
# ...... (I have removed the csv processing code for brevity)
message = EmailMessage('Invoice for 2012', 'h', 'noreply@test.co.uk', ['test@test.co.uk'])
message.attach('invoice.csv', data, 'text/csv')
message.send()
当我执行代码时,出现以下错误:
argument 1 must have a "write" method