【python】安装py3-bencode 及小例程

C:\Users\horn1\Desktop\python\35-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:\Users\horn1\Desktop\python\35-bencode-ng>python torrentParser.py
bytearray(b'37:http://www.cnblogs.com/xiandedanteng/')
bytearray(b'http://www.cnblogs.com/xiandedanteng/')

 

posted @ 2018-05-08 09:58  逆火狂飙  阅读(527)  评论(0编辑  收藏  举报
生当作人杰 死亦为鬼雄 至今思项羽 不肯过江东