Python Programming - Defining Source Code Encoding

Reading time ~1 minute

You can add the following lines at the beginning of your Python source codes to specify the encoding.

#!/usr/bin/python
# -*- coding: <encoding name> -*-

For example, you want to encode your source code in ASCII codes, you can add the following two lines at the beginning of your python source codes.

#!/usr/bin/python
# -*- coding: ascii -*-

More details you can refer to documentation of Python official site.

Useful Linux Software

Ubuntu Software Installation Continue reading

Useful user-defined LaTeX commands

Published on November 27, 2016