commit | 8641351699f44401232786cd9f320ac373c3a02e | [log] [tgz] |
---|---|---|
author | Petr Hosek <phosek@google.com> | Tue May 15 20:57:49 2018 -0700 |
committer | Petr Hosek <phosek@google.com> | Tue May 15 20:57:49 2018 -0700 |
tree | ddb3ac54a84a5bf0e2d438a10cba7e511b092c49 | |
parent | ce58143dbf1366f1c408217187c5e041b2659c7b [diff] |
Update README.fuchsia Change-Id: Ieb217be1b9923e350300bcecaebf5aa6fa6fb224
This project aims at being a specs-conforming and strict parser and writer for TOML files. The library currently supports version 0.4.0 of the specs and runs with Python 2.6+ and 3.3+.
Install:
pip install pytoml
The interface is the same as for the standard json
package.
>>> import pytoml as toml >>> toml.loads('a = 1') {'a': 1} >>> with open('file.toml', 'rb') as fin: ... obj = toml.load(fin) >>> obj {'a': 1}
The loads
function accepts either a bytes object (that gets decoded as UTF-8 with no BOM allowed), or a unicode object.
Use dump
or dumps
to serialize a dict into TOML.
>>> print toml.dumps(obj) a = 1
To run the tests update the toml-test
submodule:
$ git submodule update --init --recursive
Then run the tests:
$ python test/test.py