python基于xmlrpc实现二进制文件传输的方法
2015-06-02 00:00
1041 查看
本文实例讲述了python基于xmlrpc实现二进制文件传输的方法。分享给大家供大家参考。具体实现方法如下:
服务器端:
from SimpleXMLRPCServer import SimpleXMLRPCServer import xmlrpclib def python_logo(): handle = open("python_logo.jpg",'rb') return xmlrpclib.Binary(handle.read()) handle.close() server = SimpleXMLRPCServer(("localhost", 8000)) print "Listening on port 8000..." server.register_function(python_logo, 'python_logo') server.serve_forever()
客户端代码:
import xmlrpclib proxy = xmlrpclib.ServerProxy("http://localhost:8000/") handle = open("fetched_python_logo.jpg", "wb") handle.write(proxy.python_logo().data) handle.close()
希望本文所述对大家的Python程序设计有所帮助。
相关文章推荐
- python使用xmlrpclib模块实现对百度google的ping功能
- 使用pdb模块调试Python程序实例
- Python多进程并发(multiprocessing)用法实例详解
- python执行子进程实现进程间通信的方法
- 自己使用总结Python程序代码片段
- Python文档生成工具pydoc使用介绍
- Python中使用ElementTree解析XML示例
- python实现的守护进程(Daemon)用法实例
- Python2.x中文乱码问题解决方法
- python统计cpu利用率的方法
- Python脚本文件打包成可执行文件的方法
- Python lxml模块安装教程
- python通过ssh-powershell监控windows的方法
- Python爬取图片脚本
- Python的自定义排序 以及两种排序方式
- threading和queue监控两个log的python脚本
- python2.7+pip+virtualenv
- python学习系列(六)--- 正则表达式搜索中文
- Python开发神器-pycharm3.4.1注册版下载
- Python 入门教程--基础知识