[英]Python csv.writer without filehandler
csv.writer requires me to feed in a real csv file. csv.writer要求我提供真实的csv文件。 is there a way I can feed it a string or a list to write to instead of an actual file?
有没有一种方法可以向我提供要写入的字符串或列表而不是实际文件? I want to return the csv for another function without writing a file.
我想在不编写文件的情况下为另一个函数返回csv。
hold = [some_list]
blank = []
w = csv.writer(blank, delimiter=',')
w.writerows(hold)
return w
Traceback (most recent call last):
w = csv.writer(blank, delimiter=',')
TypeError: argument 1 must have a "write" method
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.