python 读取Excel 取出表头(列名)

#获取文件的sheep_name
import pandas as pd
df=pd.read_excel('my.xlsx',engine='openpyxl',sheet_name='中国疫情') #如果存在多个sheets,sheet_name这个必须指定

print(df.columns.to_list()) #把列名以列表的方式输出

  

测试数据文件链接:

链接: https://pan.baidu.com/s/14pKMmt7aigdMsA_fomfrMQ  密码: ahtm


如果失效,可以留言
posted @ 2021-01-15 17:03  青春叛逆者  阅读(12269)  评论(0编辑  收藏  举报