无法使用Python 2.7在Linux中下载文件
我正在使用下面的代码下载一个zip文件。但是,每次都会创建一个13kb(空)的zip文件。该代码适用于Win10,但不适用于Linux无法使用Python 2.7在Linux中下载文件,python,python-2.7,python-requests,Python,Python 2.7,Python Requests,我正在使用下面的代码下载一个zip文件。但是,每次都会创建一个13kb(空)的zip文件。该代码适用于Win10,但不适用于Linux #!/usr/bin/python import requests import datetime filedate=(datetime.datetime.now()-datetime.timedelta(days=2)).strftime("%Y%m%d") url = "http://xxxxxxxxxxxxxxxxxxxxxxxxx.zip" output
#!/usr/bin/python
import requests
import datetime
filedate=(datetime.datetime.now()-datetime.timedelta(days=2)).strftime("%Y%m%d")
url = "http://xxxxxxxxxxxxxxxxxxxxxxxxx.zip"
output_file = "/root/xxx/xxx/xxxxxxxxx"+filedate+".zip"
user='xxxxxxxxxxxxx'
password='xxxxxxx'
r = requests.get(url, auth=(user, password), stream=True, proxies={'https':'111.66.222.99:3000','http':'111.66.222.99:3000'} )
with open(output_file, 'wb') as f:
f.write(r.content)
你说的“空白”到底是什么意思?13千字节由什么组成?如果您在Linux上,为什么不使用
wget
?如果必须使用Python,可以将其封装在子流程中。(?)