首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Python将csv导入列表

Python将csv导入列表
EN

Stack Overflow用户
提问于 2014-07-10 03:48:13
回答 11查看 685.2K关注 0票数 230

我有一个包含大约2000条记录的CSV文件。

每条记录都有一个字符串和一个类别:

This is the first line,Line1
This is the second line,Line2
This is the third line,Line3

我需要将这个文件读入如下所示的列表中:

data = [('This is the first line', 'Line1'),
        ('This is the second line', 'Line2'),
        ('This is the third line', 'Line3')]

如何使用Python将此CSV导入到我需要的列表中?

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24662571

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档