当前位置: 首页 > 图灵资讯 > 行业资讯> python web.py乱码怎么解决?

python web.py乱码怎么解决?

来源:图灵python
时间: 2025-12-30 16:59:18

web.py中的中文字符串在网页上显示乱码的解决方案如下:

#!/usr/bin/envpython
#encoding:utf-8
importweb
urls=(
'/','index'
)
classindex:
defGET(self):
web.header('Content-Type','text/html;charset=UTF-8')
return"<h1>你好!</h1>"
if__name__=="__main__":
app=web.application(urls,globals())
app.run()

更多Python知识请关注Python自学网