python基于xmlrpc实现二进制文件传输的方法
作者:songguo 时间:2022-10-07 09:24:43
本文实例讲述了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,xmlrpc,文件
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
超详细Python解释器新手安装教程
2021-08-14 07:10:01
![](https://img.aspxhome.com/file/2023/0/103010_0s.png)
python 爬取华为应用市场评论
2023-08-31 23:18:32
![](https://img.aspxhome.com/file/2023/2/88972_0s.png)
Internet Explorer 8 Beta2 功能预览
2008-07-29 13:20:00
![](https://img.aspxhome.com/file/UploadPic/20087/29/2008729132347173s.jpg)
用javascript实现给出的盒子的序列是否可连为一矩型
2023-09-09 22:34:02
![](https://img.aspxhome.com/file/2023/0/56100_0s.jpg)
MySql多表查询 事务及DCL
2024-01-29 04:55:28
Python flask与fastapi性能测试方法介绍
2022-12-07 00:10:17
MySQL分区表的最佳实践指南
2024-01-27 14:45:40
利用 Python ElementTree 生成 xml的实例
2022-04-14 08:32:48
Java 正则表达式功能及应用
2022-03-25 10:07:09
Python正则表达式中的re.S的作用详解
2021-12-30 11:54:42
MySQL数据同步Elasticsearch的4种方案
2024-01-28 18:10:49
![](https://img.aspxhome.com/file/2023/6/118216_0s.jpg)
解决goland 导入项目后import里的包报红问题
2024-04-25 15:09:39
![](https://img.aspxhome.com/file/2023/1/134191_0s.jpg)
numpy增加维度、删除维度的方法
2023-12-07 22:29:01
MySQL order by与group by查询优化实现详解
2024-01-24 23:27:48
![](https://img.aspxhome.com/file/2023/7/112637_0s.png)
Python设计模式创建型原型模式
2023-07-21 21:19:25
![](https://img.aspxhome.com/file/2023/4/59124_0s.png)
python全栈开发语法总结
2021-08-25 06:16:33
从一个项目中来看三层架构
2008-08-06 12:50:00
浅谈Oracle数据库的建模与设计
2010-07-20 12:55:00
css教程–十步学会用css建站(全)[翻译]
2008-06-05 18:35:00
![](https://img.aspxhome.com/file/UploadPic/up/2008060519290921.gif)
MySQL最新漏洞分析
2012-07-11 15:41:10