Python数据分析——csv模块

1.content

reader, writer, DictReader, DictWriter.register_dialect

2.reader

import csv

reader = csv.reader(file('your.csv', 'rb'))
for line in reader:
    print line
3. writer

import csv

writer = csv.writer(file('your.csv', 'wb'))
writer.writerow(['Column1', 'Column2', 'Column3'])
lines = [range(3) for i in range(5)]
for line in lines:
    writer.writerow(line)
4. DictReader

生成一个字典(dict)类型的返回,而不是迭代类型;

5.DictWriter

可以直接获取前台的表单数据作为输入;

http://www.cnblogs.com/sislcb/archive/2008/12/15/1355481.html





你可能感兴趣的:(python)