LoginSignup
1
1

More than 5 years have passed since last update.

UTF-8で保存してるけどSyntax Error

Last updated at Posted at 2013-05-29

ものすごく基本的なことだけど、備忘録的に。

pythonのファイルをUTF-8で保存しているのに実行時にSyntax Errorが出ることがある。
たとえコメントでもascii範囲外の文字が含まれると出ると怒られるらしい。

そんな時はファイル冒頭に
# coding: utf-8
または
#-*- coding: utf-8 -*-
と記述することで解決!!

ちなみにこれはpython2.x系での話
python3.x系は書かなくても怒られなかったけど、書いておくほうが無難かな?

1
1
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
1
1