赞
踩
python直接读取网页excel文件(无需下载)
import requests import pandas as pd # excel链接 excel_url= 'xxx.com/xxx.xlsx' # 注意:这里调用网页上的excel文件,需要采用post请求 ret = requests.post(excel_url) # 保存到excel文件中,不想保存到文件,这步请忽略 # f = open("{}".format(text),"wb") # f.write(ret.content) # f.close() # 这里采用pandas读取excel数据集,转为dataframe 然后就可以对数据进行操作啦 df = pd.read_excel(ret.content,header=0) #header=0 表示指定数据集第一行作为列名,根据你的需要来定 df.head()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。