免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 9532 | 回复: 3

python如何才能打开远程服务器上的文件? [复制链接]

论坛徽章:
0
发表于 2005-07-14 21:11 |显示全部楼层
不好意思打搅大家了,我刚学python不久,以前学的是php.
请问我想在 python 中打开远程http服务器或者ftp服务器上的文件该如何操作呢?以前在php里用惯了fopen("http://XXXX","r",不过python里的open()好象加上http或者ftp不行...请问该怎么操作呢?我在baidu和google上搜索了半天也没找到解决方法,python的用户文档和几个教程也看过了,但好象讲的只是本地文件的操作...     

论坛徽章:
0
发表于 2005-07-14 23:15 |显示全部楼层

python如何才能打开远程服务器上的文件?

Python 文档里的Python Library Reference你看了吗?

第11章Internet Protocols and Support

webbrowser   Easy-to-use controller for Web browsers.
cgi   Common Gateway Interface support, used to interpret forms in server-side scripts.
cgitb   Configurable traceback handler for CGI scripts.
urllib   Open an arbitrary network resource by URL (requires sockets).
urllib2   An extensible library for opening URLs using a variety of protocols
httplib   HTTP and HTTPS protocol client (requires sockets).
ftplib   FTP protocol client (requires sockets).
gopherlib   Gopher protocol client (requires sockets).
poplib   POP3 protocol client (requires sockets).
imaplib   IMAP4 protocol client (requires sockets).
nntplib   NNTP protocol client (requires sockets).
smtplib   SMTP protocol client (requires sockets).
telnetlib   Telnet client class.
urlparse   Parse URLs into components.
SocketServer   A framework for network servers.
BaseHTTPServer   Basic HTTP server (base class for SimpleHTTPServer and CGIHTTPServer).
SimpleHTTPServer   This module provides a basic request handler for HTTP servers.
CGIHTTPServer   This module provides a request handler for HTTP servers which can run CGI scripts.
Cookie   Support for HTTP state management (cookies).
xmlrpclib   XML-RPC client access.
SimpleXMLRPCServer   Basic XML-RPC server implementation.
DocXMLRPCServer   Self-documenting XML-RPC server implementation.
asyncore   A base class for developing asynchronous socket handling services.
asynchat   Support for asynchronous command/response protocols

论坛徽章:
0
发表于 2005-07-15 09:54 |显示全部楼层

python如何才能打开远程服务器上的文件?

urllib.urlopen()就可以了。自已看例子吧。

论坛徽章:
0
发表于 2005-07-15 21:50 |显示全部楼层

python如何才能打开远程服务器上的文件?

哦,谢谢。我去试试。
Python Library Reference是不是没有中文翻译的?我搜索了一下,只找到一个年代以久而且链接全部坏死的中文翻译,哎,又得看鸟文了。。。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP