내가 파이썬과 XMLRPC에 새로 온 사람, 나는 공공 서비스에서 오는 바이너리 데이터를 디코딩와 붙어있어 :디코딩 진
이이 코드로 서비스 요청 응답은 다음과 같습니다
을from xmlrpc.client import Server
import xmlrpc.client
from pprint import pprint
DEV_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx'
logFile = open('stat.txt', 'w')
s1 = Server('http://muovi.roma.it/ws/xml/autenticazione/1')
s2 = Server('http://muovi.roma.it/ws/xml/paline/7')
token = s1.autenticazione.Accedi(DEV_KEY, '')
res = s2.paline.GetStatPassaggi(token)
pprint(res, logFile)
응답 :
: 나는이 두 바이너리 오브젝트를 디코딩해야하고,이 코드와 붙어있어{'id_richiesta': '257a369dbf46e41ba275f8c821c7e1e0',
'risposta': {'periodi_aggregazione': <xmlrpc.client.Binary object at 0x0000027B7D6E2588>,
'tempi_attesa_percorsi': <xmlrpc.client.Binary object at 0x0000027B7D9276D8>}}
끝나는
from xmlrpc.client import Server
import xmlrpc.client
from pprint import pprint
DEV_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxx'
logFile = open('stat.txt', 'w')
s1 = Server('http://muovi.roma.it/ws/xml/autenticazione/1')
s2 = Server('http://muovi.roma.it/ws/xml/paline/7')
token = s1.autenticazione.Accedi(DEV_KEY, '')
res = s2.paline.GetStatPassaggi(token)
dat = xmlrpc.client.Binary(res)
out = xmlrpc.client.Binary.decode(dat)
pprint(out, logFile)
:
Traceback (most recent call last): File "stat.py", line 18, in dat = xmlrpc.client.Binary(res) File "C:\Users\Leonardo\AppData\Local\Programs\Python\Python35\lib\xmlrpc\client.py", line 389, in init data.class.name) TypeError: expected bytes or bytearray, not dict
내가 xmlrpc.client 찾을 수있는 유일한 문서는 docs.python.org의 하나이지만, 나는이 바이너리를 디코딩 할 수있는 방법을 알아낼 수 없습니다
올바른 통화를하고있는 것 같습니다. 문제는 웹 사이트에 있습니까? 'TypeError : 예상 바이트 또는 bytearray,하지 dict'? 나는 당신이 실제로 '버라이어터'대신에 버티컬을받는다고 생각할 것이다. – NeoVe
네, 나는 그것이 딕트라고 생각합니다. 나는 웹 사이트 개발자에게 연락하려고 노력할 것이다. – Forzaferrarileo