python3无法解析种子链接

[复制链接]
查看11 | 回复0 | 2021-2-25 10:26:31 | 显示全部楼层 |阅读模式
importsys,os,hashlibimportbencode
defmain():#Opentorrentfiletorrent_file=open(sys.argv[1],rb)metainfo=bencode.bdecode(torrent_file.read())info=metainfo['info']print(hashlib.sha1(bencode.bencode(info)).hexdigest())
if__name__==__main__:main()
同样的代码,python2可以通过,python3报错。报错的信息如下:
Traceback(mostrecentcalllast):Filetesttr.txt,line14,inmodulemain()Filetesttr.txt,line9,inmainmetainfo=bencode.bdecode(torrent_file.read())Filed:\python37\Lib\site-packages\bencode.py,line68,inbdecodeBTL.BTFailure:notavalidbencodedstring
如何解决?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行