我正在执行zip文件的简单下载和编写。我首先使用了单个网址,然后下载并保存了所有内容。一旦将代码放入for循环中,它只会写入一个空的zip文件。发生什么事了?
谢谢!
import requests
def download_file(url):
print (url)
local_filename = url.split('/')[-1]
r = requests.get(url)
output = open(TempDir + '\\' + local_filename, 'wb')
output.write(r.content)
print (TempDir + '\\' + local_filename)
output.close()
for url in urllist:
download_file(url)