python通过url下载xslx、csv等文件

前提:url链接能在浏览器能够正常访问

1. 使用到的库:requests、pandas

pip install requests
pip install pandas

2、python代码

import requests
import pandas as pd
# url链接
url = ""
response = requests.get(url)
with open('file1.xlsx', 'wb') as file:
    file.write(response.content)

df = pd.read_excel('file1.xlsx')
print(df)

你可能感兴趣的:(python,数据分析)