C:Usershorn1Desktoppython35-bencode-ng>pip install py3-bencode
Collecting py3-bencode
Downloading https://files.pythonhosted.org/packages/20/07/88a2f4f3b6ca6b92dcb46b36be1f97de210ae27409ba87c97a5a615f630a/py3_bencode-0.0.2-py3-none-any.whl
Installing collected packages: py3-bencode
Successfully installed py3-bencode-0.0.2
小例程如下:
from bencode import bencode, bdecode foo = bencode('http://www.cnblogs.com/xiandedanteng/') print(foo) bar = bdecode(foo) print(bar)
输出如下:
C:Usershorn1Desktoppython35-bencode-ng>python torrentParser.py bytearray(b'37:http://www.cnblogs.com/xiandedanteng/') bytearray(b'http://www.cnblogs.com/xiandedanteng/')