【问题标题】:Python xmlrpclib parameters passingPython xmlrpclib 参数传递
【发布时间】:2015-04-09 13:44:10
【问题描述】:

我想使用 Python RPC 传递一些数据。我得到了正确的结果,但也得到了一个错误。

xmlrpclib.Fault: :invalid literal for float(): 127.0.0.1">.

我没有更改任何内容,只是突然出现错误。当我尝试使用 PRC api 传递数据时,它看起来像参数问题。但我还是没听懂。

def election_stop():
    time.sleep(5)
    while 1:
        global candidate_ids,candidate_adds,candidate_ports,lessthan
        if take_over==True and lessthan<=devices_attached:
        index_=candidate_ids.index(max(candidate_ids))
        add_s=candidate_adds[index_]
        port_s=candidate_ports[index_]
        print candidate_adds
        print "[Gateway]"+str(add_s)+str(port_s)+"win"
    try:
        proxy = xmlrpclib.ServerProxy("http://"+add_s+":"+str(port_s)+"/")
        ret = proxy.elec_recv("WIN",str(port_s),str(add_s),"you win pls takeover")
        #ret = proxy.elec_recv("LEADER",candidate_ports[0:lessthan],candidate_adds[0:lessthan],candidate_ids[0:lessthan])
        ret = proxy.elec_recv("LEADER",candidate_ports[0:lessthan],candidate_adds[0:lessthan],candidate_ids[0:lessthan])
        break
    except socket_error,exceptions.ValueError:
        print socket_error
        continue
    return "stop"
Traceback (most recent call last):
  File "./gateway.py", line 341, in <module>
    election_stop()
  File "./gateway.py", line 155, in election_stop
    ret = proxy.elec_recv("LEADER",candidate_ports[0:lessthan],candidate_adds[0:lessthan],candidate_ids[0:lessthan])
  File     "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1224, in __call__
    return self.__send(self.__name, args)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1578, in __request
    verbose=self.__verbose
   File       "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1264, in request
     return self.single_request(host, handler, request_body, verbose)
   File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1297, in single_request
     return self.parse_response(response)
   File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1473, in parse_response
     return u.close()
   File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 793, in close
     raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault 1: "<type 'exceptions.ValueError'>:invalid literal for float(): 127.0.0.1">

【问题讨论】:

  • 你能用traceback而不是图片来发布你的代码吗?
  • 很抱歉。我刚加了。我返回了(字符串,数组,数组,数组)

标签: python rpc xmlrpclib


【解决方案1】:

您将参数 "127.0.0.1" 传递给服务器上的函数,该函数需要 float 类型的参数。

【讨论】:

  • 其实不是。我不认为使用浮动。我认为一切都应该是字符串
猜你喜欢
  • 2015-11-15
  • 2019-05-21
  • 2019-12-10
  • 2012-07-07
  • 1970-01-01
  • 1970-01-01
  • 2012-09-08
  • 2016-02-08
  • 1970-01-01
相关资源
最近更新 更多