# this is the input file of csv
import csv
name = str(raw_input('please input a name : '))
tele = int(raw_input('a phone No. : '))
age = int(raw_input('age : '))
class MYCSV(csv.excel):
delimiter = "["
csv.register_dialect("mycsv",MYCSV);
mylist =[name,tele,age]
#print mylist
writer = csv.writer(open("test.mycsv","a"),MYCSV)
writer.writerow(mylist)
reader= csv.reader(open("test.mycsv"),MYCSV);
for _name ,_tele ,_age in reader:
print _name, _tele, _age
使用:新建一个 test.mycsv ,里边假设存放着,xiemx[1234567[25
解读:
1,首先新建并注册一个csv dialect。
2 ,组成一个row,然后通过writerow写入到test文件里。
3,常用的reader形式,打印出来。