西里尔符号在Python 3中不显示

时间:2017-03-29 16:38:06

标签: python python-3.x

我想编写一个接收POST(HTTP)请求并发送响应的脚本。如果POST数据具有英文字符,则会正常返回/显示它们。但是西里尔字母看起来像这样:

������ ������ �������������� ������

我的Python脚本如下:

# -*- coding: utf-8 -*-
print('Content-type: text/html\n')
import cgi
from imp import reload
form = cgi.FieldStorage()
text2 = form.getfirst("postvar1", "не задано")
print(text2)

我使用自定义服务器脚本

# -*- coding: utf-8 -*-
from http.server import HTTPServer, CGIHTTPRequestHandler
server_address = ("", 8080)
httpd = HTTPServer(server_address, CGIHTTPRequestHandler)
httpd.serve_forever()

python脚本保存为UTF-8。

如何解决这个问题?

0 个答案:

没有答案