[英]I want to write in csv file and it only write the last value (I print the value and it work but in csv not)
[英]I want to print only second row of my csv file
我只想打印 csv 文件的第二行。我有两行,但我只想获取第二行。请帮帮我。
使用下面的代码仅打印名为 f.csv 的 CSV 文件的第二行,并且每行中的数据用逗号分隔:
import csv
with open('f.csv') as csv_file:
csv_reader = csv.reader(csv_file, delimiter=',')
line_count = 0
for row in csv_reader:
if line_count == 1:
print(row)
break
line_count += 1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.