将从 Urlretrieve 下载的文件保存到其他文件夹 [英] Saving files downloaded from Urlretrieve to another folder other

查看:37
本文介绍了将从 Urlretrieve 下载的文件保存到其他文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前可以正常工作并正确下载文件,但将它们放在运行它的同一文件夹中,但是我该如何说将这些移动到 c:\downloads 或类似的东西?

Currently have this working and its downloading the files correctly but is placing them in the same folder where it is being ran from, but how would i go about say moving these to c:\downloads or something like this?

urllib.urlretrieve(url, filename)

推荐答案

filename 基本上是您对文件及其存储位置的引用.使用以下命令

filename is basically your reference to the file and where it is stored. Using the following command

fullfilename = os.path.join(myPath, filename)
urllib.urlretrieve(url, fullfilename)

您应该可以将其存储在 myPath 中.

You should be able to store it at myPath.

不要忘记放置

import os

在脚本的顶部..

这篇关于将从 Urlretrieve 下载的文件保存到其他文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆