提取表我有其中存储有这种格式的一个表文件.lua:,从.lua文件
["[email protected] - [email protected]"] = {
["someStr1"] = {
["someStr2"] = 7,
["someStr3"] = 2
}
["someStr4"] = {
["someStr5"] = 7,
["someStr6"] = 2
}
}
基本上可以有任意数量的嵌套表。我知道我要提取的初始表的名称,但是,我无法提取后续表。
with open("somePath", "rb") as file:
f = file.read()
pattern = r"\[\"[email protected][a-zA-z]+ - [a-zA-z][email protected]\"\] = \{[ \t\n]*"
guildVaults = re.findall(pattern, f)
for guild in guildVaults:
print guild
结果:
["[email protected] - [email protected]"] = {
["[email protected] - [email protected]"] = {
["[email protected] - [email protected]"] = {
["[email protected] - [email protected]"] = {
有什么建议?
编辑:这里的.lua文件的 例如: http://www.pastefile.com/Tx2LVD
不幸的是,这会产生一个空的结果。以下是如何格式化的屏幕截图:https://i.gyazo.com/8af990c1cb1711fc40db4c7a1adb74fe.png。这是隐藏第一个公会的另一个屏幕截图:https://i.gyazo.com/3353d4d40e44e547be7b45a882373b04.png – emihir0
我已经编辑了OP,并在那里放了一个直接的示例数据(.lua文件) – emihir0