例子,python读取csv文件。
代码:
复制代码 代码示例:
import csv
for line in open("test.csv"):
name,age,birthday = line.split(",")
name = name.strip(' trn');
age = age.strip(' trn');
birthday = birthday.strip(' trn');
print (name + 't' + age + 't' + birthday)
csv文件内容格式如下:
alice, 22, 1992/03/05
bob, 33, 1981/11/21
cart, 40, 1974/07/13