Last active
September 9, 2016 07:34
-
-
Save liuliqiang/cd11a6f6187c47dcd9bc1456490c2665 to your computer and use it in GitHub Desktop.
python toml examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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