Skip to content

Instantly share code, notes, and snippets.

@liuliqiang
Last active September 9, 2016 07:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liuliqiang/cd11a6f6187c47dcd9bc1456490c2665 to your computer and use it in GitHub Desktop.
Save liuliqiang/cd11a6f6187c47dcd9bc1456490c2665 to your computer and use it in GitHub Desktop.
python toml examples
import json
import toml
result = toml.loads("""
[array]
hello=['a', 'b', 'c']
arrya_with_array=[
['1', '2', '3'],
['4', '5', '6']
]
array_with_diff_type=[
[1, 2, 3],
['a', 'b', 'c']
]
""")
print json.dumps(result, indent=2)
import json
import toml
result = toml.loads("""
[[arrayoftable]]
key="value"
[[arrayoftable]]
[[arrayoftable.secondtable]] # multi level should use dot
key="value"
[[arrayoftable]]
""")
print json.dumps(result, indent=2)
import json
import toml
result = toml.loads("""
[person]
name="tyrael"
[empty]
[knowledge]
inlinetable= {name="badminton", level="4.5"}
[a.b.c]
d="e"
["name.with.dot"]
["name.withandnot.with".dot]
""")
print json.dumps(result, indent=2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment