我可以在Windows桌面上创建一个文件夹:
download_path = os.path.join(os.path.expanduser('~\\Desktop'), (file_downloads')
try:
os.mkdir(download_path)
except Exception as err:
print(err)
但是当我尝试将文件下载到其中时:
def download(file_names):
for file in file_names:
try:
urllib.request.urlretrieve(file, download_path, file.split('/')[-1])
print(f'Successfully downloaded {file}')
except Exception as err:
print(err)
我收到此错误:
[Errno 13] Permission denied
我尝试在其他目录中更改了权限,以便Everyone
拥有“完全控制”权限,但仍然出现相同的错误。我还尝试过以管理员身份从命令行运行Python文件,但仍然遇到相同的错误。