我正在尝试用我的个人时间为“银行”类型的东西创建一个基本的帐户创建器,但我遇到了问题。我创建了一个名为“newAccount”的文件来用于创建新帐户,但是当我运行它时,它只询问第一个问题,然后就停止工作了。
这是我到目前为止所拥有的。
print("What is the user's name?")
name = read()
file = io.open(name ,"w")
file:write(1, "Name: " + name, "\n")
print("What do they owe?")
owe = read()
file:write(2, "Owe: " + owe, "\n")
print("What is their account balance?")
balance = read()
file:write(3, "Balance: " + balance, "\n")
file:close(name)
停止运行后,它会显示:
newAccount:4: attempt to perform arithmetic __add on string and string
App has finished, press any key to exit."
最佳答案
Lua 使用 ..
来连接字符串,而不是 +
。改变
"Name: " + name
至
"Name: " .. name
关于lua - Lua中如何请求多行输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30657499/