我尝试在 python3 中使用它作为服务器运行一个 cgi 脚本:
from http.server import HTTPServer, CGIHTTPRequestHandler
port = 8080
httpd = HTTPServer(('', port), CGIHTTPRequestHandler)
print("Starting simple_httpd on port: " + str(httpd.server_port))
httpd.serve_forever()
但我收到以下错误:
Traceback (most recent call last):
File "/usr/lib/python3.2/http/server.py", line 1110, in run_cgi
os.execve(scriptfile, args, env)
OSError: [Errno 2] No such file or directory
localhost - - [21/Nov/2012 10:28:26] CGI script exit status 0x7f00
请帮助。
最佳答案
希望这些帮助: 1.检查你要执行的脚本是否可执行?如果不是-rwx,则不能执行 2. 检查脚本的第一行,即#! .....如果这行没有正确指向你的python所在的文件夹,还是不能执行
关于python - 使用 python 的 cgi 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13490311/