1
我試圖在Python中正確使用csv文件時在單元格中支持雙引號和逗號。繼承我編寫csv文件的代碼。用逗號和雙引號在Python中的單元格中編寫csv文件
def writecsv(filename):
if(re.match('.csv$', filename)):
filename = re.sub('\w+', filename)
try:
csvfile = open(filename, 'w', newline='')
csvwriter = csv.writer(csvfile, delimiter=',')
for row in spreadsheet[3]:
csvwriter.writerow(row)
csvfile.close()
except:
print('The file "'+filename+'" did not save correctly please try again')
現在,如果有一個雙引號它結束單元格,那麼我將如何跳過結尾雙引號之一?每個單元格都包含在一個列表中。
什麼是'電子表格'? – 101 2014-11-09 01:29:25