python基于xmlrpc实现二进制文件传输的方法
本文实例讲述了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程序设计有所帮助。
相关推荐
huavhuahua 2020-11-20
weiiron 2020-11-16
cakecc00 2020-11-15
千锋 2020-11-15
JakobHu 2020-11-14
guangcheng 2020-11-13
xirongxudlut 2020-11-10
solarLan 2020-11-09
pythonxuexi 2020-11-08
文山羊 2020-11-07
susmote 2020-11-07
wuShiJingZuo 2020-11-05
Pythonjeff远 2020-11-06
jacktangj 2020-11-04
lousir 2020-11-04
FlySky 2020-11-02
Noneyes 2020-11-10
ailxxiaoli 2020-11-16
chensen 2020-11-14