项目“;Gothonweb“;在学习Python的过程中,ex50在Ubuntu上运行良好,在win7上失败
我用ex50做了这个项目。它在ubuntu上运行良好。然而,我不能让它在win7上正常运行。怎么了?(我的代码与书中的代码完全相同!) app.py项目“;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
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/')
writerender=web.template.render('templates')
。我已对其进行了修改,但仍会发生回溯。您的问题可能出在HTML模板中。尝试在具有此功能的编辑器(如Notepad++)中保存该文件,但不使用BOM。实际上,我确实使用Notepad++编辑了该文件,并且是该格式。我已对其进行了修改,但仍会发生回溯。您的问题可能出在HTML模板中。尝试将其保存在具有此功能的编辑器(如Notepad++)中,而不使用BOM。事实上,我确实使用Notepad++编辑了该文件,它就是这种格式。