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'
答案 0 :(得分:2)
重命名CGIHTTPServer.py
。 (不要忘记删除CGIHTTPServer.pyc
。)
否则它与标准模块CGIHTTPServer
冲突;阻止您导入模块。