嘿,我不知道为什么这不起作用。我的代码从我的谷歌硬盘下载一个文件,然后把它放在一个特定的目录中。不知道为什么会这样请帮忙
错误
import os
import requests
def download(url):
directory = 'C:\Users\IEUser\AppData\Roaming'
name = url.split("/")[-1]
file_name = os.path.join(directory, name)
get_response = requests.get(url)
with open(file_name, "wb") as out_file:
out_file.write(get_response.content)
download('http://drive.google.com/u/0/uc?id=1A2Q3C2VN_8d3AHuNnWX0ZGFmhaeNHNL8&export=download')
由
name = url.split("/")[-1]
计算的文件名将包含在windows上不允许的?
。考虑从^ {< CD4> }变量中删除或替换^ {CD2> },甚至从URL中提取并使用^ {< CD5> }参数值作为文件名。为了验证这一点,在第一步中,将
name
设置为静态值,如test-download
相关问题 更多 >
编程相关推荐