import pandas
'''读取csv文件'''
a=pandas.read_csv("./animalName.csv")
print("读取的csv文件:",a,sep='\n')
读取的csv文件:
csv_name csv_times
0 dogA 1
1 dogB 10
2 dogC 11
3 dogD 1
4 catA 3
5 catB 7
6 catC 7
7 catD 8
'''读取txt文件'''
b=pandas.read_csv('./animalName.txt',header=None,encoding='gb2312',sep=',',index_col=0)
print("读取的txt文件:",b,sep="\n")
读取的txt文件:
Empty DataFrame
Columns: []
Index: [txt_name txt_times, dogA 1, dogB 10, dogC 11, dogD 1, catA 3, catB 7, catC 7, catD 8]
python之pandas学习 读取文件read_ (2)
猜你喜欢
转载自blog.csdn.net/qq_34405401/article/details/103002905
今日推荐
周排行