我需要知道如何做一些事情,比如你会在 Lua 中使用的方式:
foo={
x=7,
y=5
}
并使用 foo.x
检索变量。谢谢!
答案 0 :(得分:0)
您正在寻找一本字典,您可以在其中访问键值对。
foo={
'x':7,
'y':5
}
分号用于将键分配给值
foo = {
'key':value
}
答案 1 :(得分:0)
使用 python 字典类型:
foo = {
'x' : 7,
'y': 5
}
检索:foo['x']
官方文档如下:https://docs.python.org/3/tutorial/datastructures.html#dictionaries