25
18

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

PythonのCGIで日本語が文字化けしたときの対処法

Last updated at Posted at 2017-12-20

環境

Pythonのバージョン: Python3.6.2 32bit版
OS:Windows 10

内容

PythonのCGIスクリプトから出力したHTMLの日本語部分が文字化けする

解決方法

hello_world.py
import sys
import io
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')

のような記述でエンコード設定する

25
18
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
25
18

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?