urlopen()
不返回对象(
HTTPResponse
)您可以发送到
ZipFile()
. 你可以
read()
响应和使用
io.BytesIO()
做你需要的:
In []:
from io import BytesIO
z = urlopen('http://databank.worldbank.org/data/download/WGI_csv.zip')
myzip = ZipFile(BytesIO(z.read())).extract('WGIData.csv')
pd.read_csv(myzip)
Out[]:
Country Name Country Code Indicator Name Indicator Code 1996 \
0 Anguilla AIA Control of Corruption: Estimate CC.EST NaN
1 Anguilla AIA Control of Corruption: Number of Sources CC.NO.SRC NaN
2 Anguilla AIA Control of Corruption: Percentile Rank CC.PER.RNK NaN
3 Anguilla AIA Control of Corruption: Percentile Rank, Lower ... CC.PER.RNK.LOWER NaN
4 Anguilla AIA Control of Corruption: Percentile Rank, Upper ... CC.PER.RNK.UPPER NaN
5 Anguilla AIA Control of Corruption: Standard Error CC.STD.ERR NaN
...