如何将文件下载到服务器中的特定路径:Python [英] How to Download a file to a specific path in the server : Python

查看:439
本文介绍了如何将文件下载到服务器中的特定路径:Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过http下载文件到jython(或python)服务器上的本地文件夹

How to download a file through http on to a local folder on my server in jython(or python)

以下代码可能有效

os.chdir("/path/to/change/to")
from urllib2 import urlopen
f = urlopen("http://some.server/some/directory/some.file")

但是为此,我的当前工作目录已更改.我希望位于当前工作目录中,并将文件下载到服务器上的任何给定路径.

But for this my Current working directory is changed.I want to be in the current working directory and download the file to any given path on my Server.

有帮助吗?

推荐答案

urllib.urlretrieve

import urllib
urllib.urlretrieve('http://python.org/images/python-logo.gif', '/tmp/foo.gif')

这篇关于如何将文件下载到服务器中的特定路径:Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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