1

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'
4

1 回答 1

2

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

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

于 2014-01-17T10:56:13.420 回答