[英]How to use csv with python as an expert?
I'm just getting started on python programming.我刚刚开始 python 编程。
Here is an example of my CSV
file:这是我的
CSV
文件的示例:
Name![]() |
tag.![]() |
description![]() |
---|---|---|
Cool![]() |
cool,fun![]() |
cool...![]() |
Cell![]() |
Cell,phone![]() |
Cell...![]() |
Rang![]() |
first,third![]() |
rang...![]() |
The print with the CSV
module gives me a list of all rows, either:带有
CSV
模块的 print 为我提供了所有行的列表,或者:
['cool',''cool,fun'','cool...']
['cell',''cell,phone'','cell...']
What I want to do is to printer that cool or cell, phone我想做的是打印机那酷或手机,电话
I'm also new to programming, but I think I know what you're asking.我也是编程新手,但我想我知道你在问什么。
import csv
with open('your_file_path', 'r', newline='', encoding='utf-8') as f:
reader = csv.reader(f)
rows = list(reader)
print(rows[1][0])
print(rows[2][1])
In addition, it would be better for you to read some articles or materials processed about CSV module, such as the following:另外,你最好看看一些关于CSV模块加工的文章或资料,比如:
https://docs.python.org/3/library/csv.html#reader-objects
https://docs.python.org/3/library/csv.html#reader-objects
https://www.geeksforgeeks.org/reading-rows-from-a-csv-file-in-python
https://www.geeksforgeeks.org/reading-rows-from-a-csv-file-in-python
https://www.tutorialspoint.com/working-with-csv-files-in-python-programming
https://www.tutorialspoint.com/working-with-csv-files-in-python-programming
I am also unskilled in many places, please forgive me if there are mistakes or omissions.本人也有很多地方不熟练,如有错误或遗漏,还请多多包涵。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.