位置:首頁(yè) > 軟件操作教程 > 編程開(kāi)發(fā) > Python > 問(wèn)題詳情

多線程編程在Python中怎么實(shí)現(xiàn)?

提問(wèn)人:楊紫紅發(fā)布時(shí)間:2020-11-17

  import thread

  from SimpleXMLRPCServer import SimpleXMLRPCServer

  from xmlrpclib import ServerProxy


  def msg(s):

    print s

    return True

  def run_server():

    my_server = SimpleXMLRPCServer( ("localhost", 8001) )

    my_server.register_function(msg)

    my_server.serve_forever()


  def run_client():

    your_server = ServerProxy("http://localhost:8002")

    while True:

      msg = raw_input()

      your_server.msg(msg)


  thread.start_new_thread( run_server, () )

  run_client()

繼續(xù)查找其他問(wèn)題的答案?

相關(guān)視頻回答
回復(fù)(0)
返回頂部