2008-12-01 26 views

回答

36
import csv 

input = ['abc,"a string, with a comma","another, one"'] 
parser = csv.reader(input) 

for fields in parser: 
    for i,f in enumerate(fields): 
    print i,f # in Python 3 and up, print is a function; use: print(i,f) 

結果:

 
0 abc 
1 a string, with a comma 
2 another, one 
+0

尼斯之一。智能使用模塊:-) – 2008-12-01 14:33:42