python读写csv文件

来源:互联网 发布:模糊查询的sql语句 编辑:程序博客网 时间:2024/05/17 02:55
#Python读取Weather.csv文件内容import csvdata = [[]]f = open('Weather.csv')for line in f:    line = line.strip("\r\n")    data.append(line.split(','))f.close()#Python写入Weather_result.csv文件内容f=file('Weather_result.csv','wb')writer=csv.writer(f)writer.writerow(['outlook','temperature','humidity','windy','play'])writer.writerows(data)f.close()
0 0