Skip to main content
 首页 » 编程设计

python之如何使用Python下载文件

2025年05月04日14shihaiming

<分区>

我是 Python 的新手,我想通过向服务器发送请求来下载文件。当我在浏览器中输入它时,我看到 CSV 文件已下载,但当我尝试发送 get 请求时,它没有返回任何内容。例如:

import urllib2 
response = urllib2.urlopen('https://publicwww.com/websites/%22google.com%22/?export=csv') 
data = response.read() 
print 'data: ',  data 

它没有显示任何内容,我该如何处理?我在网上搜索的时候,都是关于如何发送get请求的问题。我可以发送获取请求,但我不知道如何下载该文件,因为它不在请求的响应中。

我不知道如何找到解决方案。