gpt4 book ai didi

python - CGIHTTPRequestHandler 给出错误

转载 作者:行者123 更新时间:2023-12-01 05:26:54 25 4
gpt4 key购买 nike

CGIHTTPRequestHandler 给出导入错误,指出没有此类模块可用。

import CGIHTTPServer

import BaseHTTPServer

class Handler(CGIHTTPServer.CGIHTTPRequestHandler):

cgi_directories = ["/cgi"]

PORT = 8000

httpd = BaseHTTPServer.HTTPServer(("", PORT), Handler)

print "serving at port", PORT

httpd.serve_forever()

我收到以下回复。

Traceback (most recent call last):
File "D:/PYTHON/cgiserver.py", line 1, in <module>
from CGIHTTPServer import CGIHTTPRequestHandler
File "D:/PYTHON\CGIHTTPServer.py", line 9, in <module>
handler = CGIHTTPServer.CGIHTTPRequestHandler
AttributeError: 'module' object has no attribute 'CGIHTTPRequestHandler'

最佳答案

重命名CGIHTTPServer.py。 (并且不要忘记删除 CGIHTTPServer.pyc。)

否则与标准模块CGIHTTPServer冲突;阻止您导入模块。

关于python - CGIHTTPRequestHandler 给出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21184144/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com