如何在代理上使用 pandas 从 url read_csv 文件?

How to read_csv file from url with pandas on proxy?

我在学生宿舍的代理上使用 pandas 读取 csv 文件时遇到问题:

drinks=pd.read_csv('https://raw.githubusercontent.com/justmarkham/pandas-videos/master/data/drinks.csv')
type(drinks)

我已经试过了,但对我没有帮助:

import pandas as pd
import io
import requests

proxy_dict = "http://proxy.rcub.bg.ac.rs:8080"

s = requests.get('https://raw.githubusercontent.com/justmarkham/pandas-videos/master/data/drinks.csv', proxies=proxy_dict).text

df = pd.read_csv(io.StringIO(s))

但我收到以下错误: enter image description here

有什么帮助吗?

你的 proxy_dict 是一个字符串,不是字典。使用

proxy_dict = {"https": "http://proxy.rcub.bg.ac.rs:8080"}