解析CSV文件時,每個人都需要「['','']」。當使用python csv模塊
我想用這個來解析一個CSV "20568078","240431","jpg","St, Carolina 1920",,
到["20568078","240431","jpg","St, Carolina 1920","",""]
:
string=r'"20568078","240431","jpg","St, Carolina 1920",,'
reader = csv.reader(string)
for r in reader:
print (r)
我得到的輸出:
['20568078']
['', '']
['240431']
['', '']
['jpg']
['', '']
['St, Carolina 1920']
['', '']
['', '']
我想konw如何刪除不必要['', '']
,並將最後兩個,,
更改爲""
和""
謝謝。
+1學到新的東西 – HennyH 2013-05-14 06:46:01
所以發生了什麼事在OP的代碼? – Eric 2013-05-14 06:51:39
@Eric我更新了那個信息 – jamylak 2013-05-14 07:00:46