我正在尝试编写 csv 文件并将它们返回到响应正文中,但我得到了
TypeError: object of type '_csv.writer' has no len()
下面是我的代码:
class LogCSV(object):
"""CSV generator.
This class responds to GET methods.
"""
def on_get(self, req, resp):
"""Generates CSV for log."""
mylist = [
'test','one'
]
myfile = open('testingcsv', 'w')
wr = csv.writer(myfile, quoting=csv.QUOTE_ALL)
wr.writerow(mylist)
resp.status = falcon.HTTP_200
resp.content_type = 'text/csv'
resp.body = (wr)
我不明白这个错误。