tag_csv数据:
image.png
第一种以with open as + csv.reader()读取
import csv
import pandas as pd
filepath = 'tag.csv'
# 第一种以with open as + csv.reader()读取
p = []
with open(filepath, 'r', encoding="UTF-8") as fr:
reader = csv.reader(fr)
for index, line in enumerate(reader):
if index == 0:
continue
p.append(line)
第二种 用pd.read_csv()
df = pd.read_csv(filepath)
print("reader:", reader)
print("-------------------------")
print("line:", line)
print("-------------------------")
print("P", p)
print("-------------------------")
print(df)
网友评论