python 中如何对csv表格文件进行操作?增加一列?提取每一行中的第二列?

在线等....尴尬
2024-12-31 22:35:14
推荐回答(1个)
回答1:

pip install pyexcel

读取文件以后,在重新写入文件就可以了。
import pyexcel as pe
import pyexcel.ext.xls # import it to handle xls file
import pyexcel.ext.xlsx # import it to handle xlsx file
records = pe.get_records(file_name="your_file.xls")
for record in records:
print("%s is aged at %d" % (record['Name'], record['Age']))