Python读写csv文件
2014-07-10 11:14
661 查看
1. 写csv文件
2.读csv文件
# coding: utf-8 import csv csvfile = file('csv_test.csv', 'wb') writer = csv.writer(csvfile) writer.writerow(['姓名', '年龄', '电话']) #写入单行 data = [ ('小河', '25', '1234567'), ('小芳', '18', '789456') ] writer.writerows(data) #写入多行 csvfile.close()
2.读csv文件
# coding: utf-8 import csv csvfile = file('csv_test.csv', 'rb') reader = csv.reader(csvfile) for line in reader: print line csvfile.close()
相关文章推荐
- Python读写CSV文件
- python3使用csv模块读写csv文件
- python 读写csv文件(一)
- python中文件的读写——read_csv()读取文件
- python简单的读写csv文件
- Python读写csv文件
- Python读写CSV文件--追加方式多空行
- Python读写csv文件
- python读写csv文件
- python数据分析之(4)读写数据文件CSV,EXCEL等
- Python读写csv文件
- (4)Python读写csv文件
- python 读写csv格式文件
- python3使用csv模块读写csv文件
- Python CSV文件处理/读写
- Python读写csv文件
- python读写csv文件
- python 读写 csv文件
- Python——csv txt文件读写
- Python读写csv文件