服務(wù)端程序在Python中怎么實(shí)現(xiàn)?
提問人:楊紫紅發(fā)布時(shí)間:2020-11-17
from SimpleXMLRPCServer import SimpleXMLRPCServer
def msg(s):
print s
return True
server = SimpleXMLRPCServer( ("localhost", 8000) )
server.register_function(msg)
server.serve_forever()
對(duì)應(yīng)的客戶機(jī)程序:
from xmlrpclib import ServerProxy
server = ServerProxy("http://localhost:8000")
while True:
msg = raw_input()
server.msg(msg)
繼續(xù)查找其他問題的答案?
相關(guān)視頻回答
點(diǎn)擊加載更多評(píng)論>>