小编haw*_*290的帖子

lua 中的多行函数表

我似乎找不到任何其他有关创建包含多行函数的表的在线帮助。例如,这里是来自 lua wiki 的一段代码。

action = {
  [1] = function (x) print(1) end,
  [2] = function (x) z = 5 end,
  ["nop"] = function (x) print(math.random()) end,
  ["my name"] = function (x) print("fred") end,
}
Run Code Online (Sandbox Code Playgroud)

我想做这样的事情:

action = {
[1] = function blah()
more code here
end

[2] = function blahblah()
more code here
end

}
Run Code Online (Sandbox Code Playgroud)

那么我该怎么做呢?

lua

3
推荐指数
1
解决办法
2042
查看次数

Elif如果不工作或我不理解

好吧,我的代码正在运行,但是当我输入No时,如果我想重试输入密码则不起作用; 它只是进入输入密码行(第20行).我已经尝试了多种方法来解决这个问题,但我根本做不到.

import time
import os

print ("Hello world.")
time.sleep(1)
print ("Waiting 5 seconds.")
time.sleep(5)
print ("You have waited 10 seconds.")
print ("Executing Chrome.")
time.sleep(1)
print ("Execution failed!")
password = input("Enter the execution password: ")
if password == 'password1234':
    os.system ('C:\\Users\\Harry\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe')
else:
    print ("Wrong password!")
    time.sleep(1)
    passretry = input("Do you want to try again? ")
    if passretry == 'yes' or 'Yes':
        passretry1 = input("Enter password: ") 
        if passretry1 == 'password1234':
            os.system ('C:\\Users\\Harry\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe')
    elif passretry == 'no' or 'No':
        print ("Closing...") …
Run Code Online (Sandbox Code Playgroud)

python if-statement

0
推荐指数
1
解决办法
1152
查看次数

标签 统计

if-statement ×1

lua ×1

python ×1