Converting .lua Table To A Python Dictionary
I have this kind of input: sometable = { ['a'] = { 'a1', }, ['b'] = { 'b1', ['b2'] = true, }, ['c']
Solution 1:
Look at this package: https://github.com/SirAnthony/slpp.
>>> from slpp import slpp as lua
>>> code = """{
["a"] = {
"a1",
},
["b"] = {
"b1",
["b2"] = true,
},
["c"] = {
"c1",
["c2"] = true,
},
}"""
>>> print(lua.decode(code))
{'a': ['a1'], 'c': {0: 'c1', 'c2': True}, 'b': {0: 'b1', 'b2': True}}
Post a Comment for "Converting .lua Table To A Python Dictionary"