AttributeError:module' cherrypy'没有属性'暴露'

时间:2017-02-15 23:11:12

标签: python cherrypy

我已经在virtualenv中使用pip安装了cherrypy并运行了第一个教程:

import cherrypy


class HelloWorld(object):
    @cherrypy.expose
    def index(self):
        return "Hello world!"


if __name__ == '__main__':
    cherrypy.quickstart(HelloWorld())

它抛出错误:

Traceback (most recent call last):
  File "C:/wc/playground/scripts/cherrypy.py", line 1, in <module>
    import cherrypy
  File "C:\wc\playground\scripts\cherrypy.py", line 4, in <module>
    class HelloWorld(object):
  File "C:\wc\playground\scripts\cherrypy.py", line 5, in HelloWorld
    @cherrypy.expose
AttributeError: module 'cherrypy' has no attribute 'expose'

任何人都知道为什么?

0 个答案:

没有答案