import csv FIELDS = ['Name', 'Sex', 'E-mail', 'Blog'] # DictWriter csv_file = open('test.csv', 'wb') writer = csv.DictWriter(csv_file, fieldnames=FIELDS) # write header writer.writerow(dict(zip(FIELDS, FIELDS))) d = {} d['Name'] = 'Qi' d['Sex'] = 'Male' d['E-mail'] = 'redice@163.com' d['Blog'] = 'http://www.redicecn.com' writer.writerow(d) csv_file.close() # For results, please see following picture # DictReader # A easier way for skipping the header # Usually we need a extra flag variables for d in csv.DictReader(open('test.csv', 'rb')): print d # Output: # {'Blog': 'http://www.redicecn.com', 'E-mail': 'redice@163.com', 'Name': 'Qi', 'Sex': 'Male'}
呵呵,谢谢
VaTG790i.最好的<a href=http://www.kyfei.com>网站推广软件</a>,
非常好
....................
;ui;普i;uighur;ui;ui;个
在unix网络编程中看到了关于TCP/IP的一些内容,我感觉还是写的不够。正在下载中,一定
下载地址呢