- python获取行号excel
import pandas as pd def finddata(): demo_df=pd.read_excel(r'C:\Users\Asus\Downloads\网上充值明细20230224093351.xlsx') ##文件路径 print(demo_df) for indexs in demo_df.index: for i in range(len(demo_df.loc[indexs].values)): if (demo_df.loc[indexs].values[i] == "31048800000000017531"): print('行数:',indexs+4, '列数:',i+1) print(demo_df.loc[indexs].values[i]) #print('行数:',indexs+2) # else: # #显示行数 # print('没有找到信息') if __name__ == '__main__': finddata()
- 封装的太好了,读取excel 还没有进程残留
-