用于python的bencodex读写器
bencodex的Python项目详细描述
此包实现扩展Bencoding的Bencodex序列化格式。
用法
这个包的api遵循了python的pickle和^{tt2}的传统$ 模块:
- bencodex.dump(obj: bencodex.BValue, fileobj: typing.BinaryIO) -> None
- bencodex.dumps(obj: bencodex.BValue) -> bytes
- bencodex.load(fileobj: typing.BinaryIO) -> bencodex.BValue
- bencodex.loads(encoded: bytes) -> bencodex.BValue
示例
>>> from bencodex import dumps, loads >>> dumps({'name': 'Jane Doe', 'age': 30, 'nationality': ['BR', 'US']}) b'du3:agei30eu4:nameu8:Jane Doeu11:nationalitylu2:BRu2:USee' >>> loads(_) {'age': 30, 'name': 'Jane Doe', 'nationality': ['BR', 'US']}
许可证
分布在GPLv3或更高版本下。