csv - python - 无法从网站下载CSV文件


import requests


import os



url = 'http://www.football-data.co.uk/mmz4281/1920/E0.csv'



response = requests.get(url)


with open(os.path.join("folder","file"), 'wb') as f:


 f.write(response.content)



时间: 原作者:

另外,您可以尝试使用可从URL读取CSV文件的熊猫。代码将变成:


import pandas as pd


import csv



url = '{Some CSV target}'


df = pd.read_csv(url)


df.to_csv('{absoulte path to CSV}', sep=',', index=False, quoting=csv.QUOTE_ALL)



原作者:
...