如何在 Lua中从表格中获取值?

我在 Lua 中有一个表格:

localhost:3301> box.space.S24.index[1].parts
---
- - type: string
    is_nullable: false
    fieldno: 1
...

我想要获取键 fieldno 对应的值。但是当我输入下面的代码时:

localhost:3301> box.space.S24.index[1].parts.fieldno
---
- null
...

我得到了 null。

点赞
用户4984564
用户4984564

你在输出中缺少第二个 -;它是嵌套在一个数组中的数组。尝试 ...parts[1].fieldno

2019-10-11 17:46:07