【发布时间】:2011-09-21 02:28:44
【问题描述】:
我正在开发一个项目,最终用户将运行 Lua,并与用 Python 编写的服务器进行通信,但我找不到在 Lua 中做我需要做的事情的方法。
我给程序一个输入:
recipient command,argument,argument sender
我得到一个列表的输出,其中包含:
{"recipient", "command,argument,argument", "sender"}
然后,将这些项目分成单独的变量。之后,我会将command,argument,argument 分离到另一个列表中,然后再次将它们分离到变量中。
我是如何在 Python 中做到的:
test = "server searching,123,456 Guy" #Example
msglist = test.split()
recipient = msglist.pop(0)
msg = msglist.pop(0)
id = msglist.pop(0)
cmdArgList = cmd.split(',')
cmd = cmdArgList.pop(0)
while len(cmdArgList) > 0:
argument = 1
locals()["arg" + str(argument)]
argument += 1
【问题讨论】:
标签: python list lua equivalent