Defining Python Source Code Encodings

Defining the Encoding

    Python will default to ASCII as standard encoding if no other
    encoding hints are given.

    To define a source code encoding, a magic comment must
    be placed into the source files either as first or second
    line in the file, such as:

          # coding=<encoding name>

    or (using formats recognized by popular editors)

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

 

#-*— coding:utf-8 -*-

  

posted @ 2017-01-19 12:24  KennyRom  阅读(303)  评论(0编辑  收藏  举报