python 的 RPC

bigzhu posted @ Oct 17, 2007 08:40:00 PM in python , 1168 阅读

非常的简单

SimpleXMLRPCServer

代码如下

#!/usr/bin/env python
#coding=utf-8
import sys
from random import shuffle
from SimpleXMLRPCServer import SimpleXMLRPCServer

class MyFuncs:
def reverse(self, str) :
x = list(str);
x.reverse();
return ”.join(x);
def scramble(self, str):
x = list(str);
shuffle(x);
return ”.join(x);

server = SimpleXMLRPCServer((“localhost”, 8000))
server.register_instance(MyFuncs())
server.serve_forever()



登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter