第一种:使用with open方法
第二种:使用csv.reader方法
第三种:使用pd.read_csv方法
代码如下:
with open("word.csv",encoding='utf-8') as file:
contents = file.readlines()
for line in contents:
print(line)
import csv
csv_reader = csv.reader(open("word.csv",encoding='utf-8'))
for row in csv_reader:
print(row)
#pandas比较强在F列(explanation)中寻找“常用语人名”De汉字
import pandas as pd
data = pd.read_csv("word.csv",encoding='utf-8')
print(data)
推荐使用pandas读取
最后
以上就是香蕉大米最近收集整理的关于python中使用原生方法和使用pandas读取csv文件的三种方式的全部内容,更多相关python中使用原生方法和使用pandas读取csv文件内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复