【将.lua表转换为python字典】教程文章相关的互联网学习教程文章

将.lua表转换为python字典【代码】

我有这种输入:sometable = {["a"] = {"a1",},["b"] = {"b1",["b2"] = true,},["c"] = {"c1",["c2"] = true,},},并想将其转换为我可以在python中使用的字典-或基本上,我只需要能够以这种模式读取数据:print sometable[b][b2]最好的解决方案是什么?我试图做一堆替换并使用ast进行转换,即:def make_dict(input): # just body, ie. without 'sometable'input = input.replace("=", ":")input = input.replace("[\"", "\"")input = ...