python

超轻量级php框架startmvc

python实现对csv文件的列的内容读取

更新时间:2020-06-08 22:42:01 作者:startmvc
以下代码测试在python2.7mac上运行成功importcsvwithopen('/Users/wangzhao/Downloads/test.csv','U')ascsvfile:rea

以下代码测试在python2.7 mac上运行成功


import csv

with open('/Users/wangzhao/Downloads/test.csv', 'U') as csvfile:
 reader = csv.DictReader(csvfile)
 column = [row['Employee Name'] for row in reader]
print column

import csv
with open('/Users/wangzhao/Downloads/test.csv', 'U') as csvfile:
 reader = csv.reader(csvfile)
 column = [row[2] for row in reader]
print column

以上这篇python实现对csv文件的列的内容读取就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。

python csv文件 读取