我有一个字符串列表并保存到 csv 文件
imagesList=['img/201507/27/e731.gif','img/201507/29/e771.png']
myCSV =csv.writer(open('data.csv', 'wb'))
myCSV.writerow([imagesList])
像这样打开csv文件:
"['img/201507/27/e731.gif', 'img/201507/29/e771.png']"
但我想得到这样的
"["img/201507/27/e731.gif", "img/201507/29/e771.png"]"
所以我改变了代码
import csv
imagesList=['img/201507/27/e731.gif','img/201507/29/e771.png']
imgList = []
for image in imagesList:
image = '"'+image+'"'
imgList.append(image)
myCSV =csv.writer(open('data1.csv', 'wb'))
myCSV.writerow([imgList])
但我得到:
"['""img/201507/27/e731.gif""', '""img/201507/29/e771.png""']"
那么如何删除单引号(')?