CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
jackfrued

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: jackfrued/Python-100-Days
Path: blob/master/Day01-15/code/Day11/csv1.py
Views: 729
1
"""
2
读取CSV文件
3
4
Version: 0.1
5
Author: 骆昊
6
Date: 2018-03-13
7
"""
8
9
import csv
10
11
filename = 'example.csv'
12
13
try:
14
with open(filename) as f:
15
reader = csv.reader(f)
16
data = list(reader)
17
except FileNotFoundError:
18
print('无法打开文件:', filename)
19
else:
20
for item in data:
21
print('%-30s%-20s%-10s' % (item[0], item[1], item[2]))
22
23