LoginSignup
24
18

More than 5 years have passed since last update.

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')

と記述して設定すればOK

24
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
24
18