有很多种子文件,有时候记不清里面都是什么东西,又不想一个一个的拖放到迅雷或BT软件里头看,
上网查了一下Python的脚本,自己也稍微修改了一下,代码如下,粘贴到文本编辑器中:
保存成py后缀的,直接运行
importre deftokenize(text, match=re.compile("([idel])|(/d+):|(-?/d+)").match): i=0 whileiling junk") except(AttributeError, ValueError, StopIteration): raiseSyntaxError("syntax error") returndata if__name__=="__main__": #需要读取的文件名称放到这里 data=open("The_Shawshank_Redemption.torrent","rb").read() torrent=decode(data) myfile=file("testit.txt","w") a=u"文件名称".encode("gbk") b=u"文件大小".encode("gbk") print"%s /t %s /n"%(a,b) forfileintorrent["info"]["files"]: print"%s /t %d Mb "%("/".join(file["path"]),file["length"]/1024/1024) print"-----------------------------------------------------------------"
注意要保存成Utf-8格式的文件,不能使用ASCII编码格式保存,否则中文会乱码或无法编译
【python json解析】Python实现解析Bit Torrent种子文件内容的方法
http://m.bbyears.com/jiaocheng/135772.html
推荐访问:python解析xml