前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >python解析torrent文件库:p

python解析torrent文件库:p

作者头像
py3study
发布2020-01-03 17:14:04
2.3K0
发布2020-01-03 17:14:04
举报
文章被收录于专栏:python3python3python3

pytorrent是一个非常小巧的用来解析解析torrent文件python库。核心代码不足150行,却能够完备地解析torrent文件,并支持导出修改后的torrent文件。

使用演示:

import pytorrent
t=pytorrent.Torrent()
t.load("test.torrent")  #your torrent file
print t.data["info"]["name"].decode("utf-8")
files=t.data["info"]["files"]
for item in files:
    print item["path"][0].decode("utf-8")
t.data["info"]["name"]="my_name" #change info.
t.dump("dump.torrent")  #the new torrent file

该库把torrent文件结构映射到python的dict,list,integer,string四种类型,直接操作这四种数据就能读取和修改torrent文件的一切信息。

项目地址

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019-09-24 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档