Python 学习3 读写excel数据

时间:2014-12-19 17:20:27   收藏:0   阅读:162

读取excel 文件的数据

import csv
with open(D:/mystuff/11.csv,r) as f:
    reader = csv.reader(f)
    for row in reader:
        print(row)
        

写入excel文件

import csv
with open(D:/mystuff/33.csv, mode=w) as csvfile:
    #w1=csv.writer(csvfile,delimiter=‘ ‘,quotechar="|",quoting=csv.QUOTE_MINIMAL)
    w1=csv.writer(csvfile,dialect=excel)
    w1.writerow([1,2,3,4])
    w1.writerow([11,22,33,44])
    w1.writerow(["chenfenping","","",""])
    w1.writerow(["cx"])

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!