如何从wsgi2.0.13和核心python3.4应用程序打印UTF8字符

2024-03-29 14:38:47 发布

您现在位置:Python中文网/ 问答频道 /正文

我是python编程新手,使用的是uwsgi2.0.13.1和python3.4.4 以下是对我来说运行得非常好的代码:

def application(environ, start_response):
    start_response('200 OK', [('Content-Type', 'text/html; charset=utf-8')])
    return [b"<h1 style='color:blue'>Hello There!</h1>"]

现在,我想返回UTF-8字符。所以,我修改了代码如下,并添加了一些字符,如“অउष”

^{pr2}$

现在代码运行正常,但它不会在浏览器屏幕上打印任何内容。在

如果我们改变这条线

^{3}$

return [abc.encode()]

然后它会打印一些其他字符而不是“অउष”。 有人能帮我解决这里出什么问题吗?

以下是我的wsgi.ini文件文件配置:

[uwsgi]
http-socket = 127.0.0.1:3031
chdir = /var/www/html/python_test/
wsgi-file = /var/www/html/python_test/test.py
processes = 4
threads = 2
master = true
stats = 127.0.0.1:9191
encoding = "utf-8"

Tags: 文件代码testwsgireturnresponsevarhtml
1条回答
网友
1楼 · 发布于 2024-03-29 14:38:47

我在用

start_response('200 OK', [('Content-Type', 'text/html;')])

而不是

^{pr2}$

现在它对我起作用了。在

相关问题 更多 >