转载:https://www.py.cn/spider/advanced/14381.html
import csv with open('C:\\Users\\del\\Desktop\\123.csv', 'r') as csvfile: reader = csv.reader(csvfile) for row in reader: print(row)
执行结果:
['1', '1啊', '1a']
['2', '2的', '2好']
['3', '3银行', '3shd']
==========================================================================
import csv
users = []
with open('C:\\Users\\del\\Desktop\\123.csv', 'r') as csvfile:
reader = csv.reader(csvfile)
for row in reader:
print(row)
users.append(row)
print(type(users))
print(users)
print(len(users))
print(users[0])
print(users[0][0])
print(users[0][1])
print(users[0][2])
执行结果:
['1', '1啊', '1a']
['2', '2的', '2好']
['3', '3银行', '3shd']
<class 'list'>
[['1', '1啊', '1a'], ['2', '2的', '2好'], ['3', '3银行', '3shd']]
3
['1', '1啊', '1a']
1
1啊
1a
==============================================================================