当我尝试创建一个新的csv文件并向其中添加行时,它将在每行的开头和结尾添加““”。如何解决此问题?
Instead of using the csv
library, you could simply output the file as such:
>>> x = [1,2,3,4,5]
>>> x = map(str,x)
>>> with open('out.csv','w') as fout:
... fout.write(','.join(x))
...
>>> with open('out.csv','r') as fin:
... print fin.read().split(',')
...
['1', '2', '3', '4', '5']
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.