我如何终止Lua脚本?现在我遇到了exit()问题,我不知道为什么.(这更多是Minecraft ComputerCraft的问题,因为它使用了包含的API.)这是我的代码:
while true do
if turtle.detect() then
if turtle.getItemCount(16) == 64 then
exit() --here is where I get problems
end
turtle.dig() --digs block in front of it
end
end
Run Code Online (Sandbox Code Playgroud) 我正在我的Raspberry Pi上设置一个简单的Web服务器,我似乎无法正确设置lighttpd,fastcgi和flask.
到现在为止,我经历了几次迭代/etc/lighttpd/lighttpd.conf,最近的一次
fastcgi.server = ("/test" =>
"test" => (
"socket" => "/tmp/test-fcgi.sock",
"bin-path" => "/var/www/py/test.fcgi",
"check-local" => "disable"
)
)
Run Code Online (Sandbox Code Playgroud)
那吐了一个错误/etc/init.d/lighttpd start.第一行看起来不对,所以我在胖箭后添加了一组parens:
fastcgi.server = ("/test" => (
...
))
Run Code Online (Sandbox Code Playgroud)
这没有发出错误,但当我尝试连接时,我进入ERR_CONNECTION_REFUSED了Chrome.然后我尝试删除"/test" =>,这有同样的问题.我也试过这个问题中显示的配置,并且发生了同样的问题.
在/var/www/py/test.fgci:
#!/usr/bin/python
from flup.server.fcgi import WSGIServer
from test import app
WSGIServer(app, bindAddress="/tmp/test-fcgi.sock").run()
Run Code Online (Sandbox Code Playgroud)
在/var/www/py/test.py:
from flask import Flask
app = Flask(__name__)
@app.route("/test")
def hello():
return "<h1 style='color:red'>☭ hello, comrade ☭</h1>"
Run Code Online (Sandbox Code Playgroud)
lighttpd.conf当我启动它时,电流失败/etc/init.d/lighttpd …
这可能吗?我看过的每个答案都不是我想要的.我所做的就像是omega-rpg(这是一个很棒的基于文本的debian RPG),但是在Python而不是C.我已经四处寻找并发现了一些东西,但没有任何与我正在做的事情相关的东西.是否更容易使用raw_input()/ input,或者使用某种API这样做会更有效吗?
打扫干净:
我需要一个Python实时键盘输入系统,但我不知道使用API或仅使用它是否更容易raw_input() / input().如果最好使用API,这对初学者级程序员来说是最好的?
额外:
任何解决方案都将用于基于文本的游戏!请在回答时记住这一点.
我本周末在Rust重新做一个项目,我需要将i32转换为ASCII字符,使用它作为字符代码.到目前为止我所有的都是一个可怕的match,我隐藏在文件的末尾.不幸的是,std::ascii不支持这种转换.目前我只是在寻找一种不那么荒谬/更像Rust(?)的方法来做到这一点.
fn to_ascii(i: &i32) -> String {
let a = match *i {
0 => "NUL",
1 => "SOH",
2 => "STX",
// ...
125 => "}",
126 => "~",
127 => "DEL",
_ => "",
}
a
}
Run Code Online (Sandbox Code Playgroud)