我正在尝试将response
从utorrent
dht网络从bytes
转换为string
,但是我得到了UnicodeDecodeError
错误
ping_query = {
't': '0f',
'y': 'q',
'q': 'ping',
'a': {'id': client_id}}
ping_query = bencode.encode(ping_query)
host = socket.gethostbyname('router.utorrent.com')
port = 6881
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s:
s.connect((host, port))
s.send(ping_query)
r = s.recvfrom(1024)
response_data = bencode.decode(r[0])
print(response_data['ip'].decode('utf-8'))
但是我得到了错误UnicodeDecodeError: 'utf-8' codec can't decode byte 0xeb in position 0: invalid continuation byte
response_data['ip']
示例:b'\xeb\xff6isQ\xffJ\xec)\xcd\xba\xab\xf2\xfb'
有什么想法吗?你知道吗
编辑:这是来自r
:b'd2:ip6:\x80j\xe4\x01\xea\xdb1:rd2:id20:\xeb\xff6isQ\xffJ\xec)\xcd\xba\xab\xf2\xfb\xe3F|\xc2ge1:t2:xd1:y1:re'
的原始响应
目前没有回答
相关问题 更多 >
编程相关推荐