Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
项目“;Gothonweb“;在学习Python的过程中,ex50在Ubuntu上运行良好,在win7上失败_Python - Fatal编程技术网

项目“;Gothonweb“;在学习Python的过程中,ex50在Ubuntu上运行良好,在win7上失败

项目“;Gothonweb“;在学习Python的过程中,ex50在Ubuntu上运行良好,在win7上失败,python,Python,我用ex50做了这个项目。它在ubuntu上运行良好。然而,我不能让它在win7上正常运行。怎么了?(我的代码与书中的代码完全相同!) app.py import web urls = ( '/', 'Index' ) app = web.application(urls, globals()) render = web.template.render('templates/') class Index(object): def GET(self): greet

我用ex50做了这个项目。它在ubuntu上运行良好。然而,我不能让它在win7上正常运行。怎么了?(我的代码与书中的代码完全相同!)

app.py

import web
urls = (
   '/', 'Index'
)
app = web.application(urls, globals())

render = web.template.render('templates/')

class Index(object):
    def GET(self):
        greeting = "Hello World"
    return render.Index(greeting = greeting)

if __name__ == "__main__":
    app.run()
win7上的回溯:
我在github上的项目~

不要在Windows上使用尾随的
/
。不要在Windows上使用尾随的
/
而不是
render=web.template.render('templates/')
write
render=web.template.render('templates')
。我已对其进行了修改,但仍会发生回溯。您的问题可能出在HTML模板中。尝试在具有此功能的编辑器(如Notepad++)中保存该文件,但不使用BOM。实际上,我确实使用Notepad++编辑了该文件,并且是该格式。我已对其进行了修改,但仍会发生回溯。您的问题可能出在HTML模板中。尝试将其保存在具有此功能的编辑器(如Notepad++)中,而不使用BOM。事实上,我确实使用Notepad++编辑了该文件,它就是这种格式。