用urlretrieve下载文件时,出现PermissionError,怎么办?

MPath = 'D:\\Python' if not os.path.exists(MPath): os.mkdir(MPath) urllib.r…
关注者
5
被浏览
2,904

3 个回答

你怎么想filename这个参数都应该是一个文件而不是文件夹啊,换成D:\\Python\\mydownload.data

想要更智能的可以试试requests之类的库,urlretrieve是不行

filename是文件名,不是目标目录。你要带上目标文件名才行,比如r'd:\python\foo.bar'