Python

Python "Hello, World!" ""

Python

#!/usr/bin/python

print ("")

  File "test.py", line 2
SyntaxError: Non-ASCII character '\xe4' in file test.py on line 2, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

Python ASCII

# -*- coding: UTF-8 -*- # coding=utf-8

# coding=utf-8 =

(Python 2.0+)

#!/usr/bin/python # -*- coding: UTF-8 -*- print( "" )


Python3.X utf-8 UTF-8

py UTF-8

SyntaxError: (unicode error) ‘utf-8’ codec can’t decode byte 0xc4 in position 0:
invalid continuation byte

Pycharm

  • file > Settings encoding
  • Editor > File encodings IDE Encoding Project Encoding utf-8

pycharm-utf8.jpg [pycharm-utf8.jpg]