Python Data Visualization Cookbook 2.2.2

 import csv

 filename = 'ch02-data.csv'
data = [] try:
with open(filename) as f://用with语句将数据文件绑定到对象f
reader = csv.reader(f)
header = next(reader)//Python 3.X 用的是next()
data = [row for row in reader]
except csv.Error as e:
print('Error reading CSV file at line %s: %s' % (reader.line_num,e) )
sys.exit(-1) if header:
print(header)
print("=======================")
for row in data:
print(row)
上一篇:更改Pch配置


下一篇:kubernetes实战(九):k8s集群动态存储管理GlusterFS及使用Heketi扩容GlusterFS集群