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'发布于 2014-01-17 10:56:13
改名为CGIHTTPServer.py.(别忘了删除CGIHTTPServer.pyc。)
否则,它将与标准模块CGIHTTPServer发生冲突;阻止您导入该模块。
https://stackoverflow.com/questions/21184144
复制相似问题