python dict格式的转储程序。
dictdumper的Python项目详细描述
听写转储程序
dictdumper
项目是一个开源的python程序,用作dict
的流格式输出转储程序。
- About
dictdumper.Dumper
dictdumper.JSON
dictdumper.PLIST
dictdumper.Tree
dictdumper.XML
dictdumper.HTML
- Installation
- Usage
关于
目前支持以下格式--
dictdumper.Dumper
——所有转储程序的抽象基类dictdumper.JSON
——转储javascript对象表示法(JSON
)格式文件dictdumper.PLIST
——转储Apple属性列表(PLIST
)格式文件dictdumper.Tree
——转储树视图文本(TXT
)格式文件dictdumper.XML
——转储可扩展标记语言(XML
)文件(基类)dictdumper.HTML
——在Vue.js
框架下转储javascript文件(已弃用)
安装:
Note that
dictdumper
supports Python versions 2.7 and all versions since 3.0
pip install dictdumper
使用量
dictdumper
很容易使用。在安装、导入和初始化之后,您可以简单地调用实例来转储内容。
Take
dictdumper.Tree
for example
importdictdumperdumper=dictdumper.Tree('out.txt')test_1=dict(foo=-1,# intbar='Hello, world!',# stringboo=dict(# dictfoo_again=True,# boolbar_again=b'bytes',# bytes (b'\x62\x79\x74\x65\x73')boo_again=None,# NoneType),)dumper(test_1,name='test_1')
$ cat out.txt
PCAP File Tree-View Format
test
|-- foo -> -1
|-- bar -> hello
|-- boo
|-- foo_again -> True
|-- bar_again -> 62 79 74 65 73
|-- boo_again -> N/A
importdatetimetest_2=dict(foo=[1,2.0,3],# listbar=(1.0,2,3.0),# tupleboo=dict(# dictfoo_again='a long long bytes',# bytesbar_again=datetime.datetime.today(),# datetimeboo_again=-1.0,# float),)dumper(test_2,name='test_2')
$ cat out.txt
PCAP File Tree-View Format
test_1
|-- foo -> -1
|-- bar -> Hello, world!
|-- boo
|-- foo_again -> True
|-- bar_again -> 62 79 74 65 73
|-- boo_again -> N/A
test_2
|-- foo
| |--> 1
| |--> 2.0
| |--> 3
|-- bar
| |--> 1.0
| |--> 2
| |--> 3.0
|-- boo
|-- foo_again -> a long long bytes
|-- bar_again -> 2018-03-08 17:47:35
|-- boo_again -> -1.0