How will you specify source code encoding in a Python source file?

By default, every source code file in Python is in UTF-8 encoding. But we can also specify our own encoding for source files. This can be done by adding following line after #! line in the source file.

# -*- coding: encoding -*-

In the above line we can replace encoding with the encoding that we want to use.

Leave a Reply

Your email address will not be published. Required fields are marked *