Why declare unicode by string in python?

后端 未结 5 2155
南笙
南笙 2020-11-27 10:45

I\'m still learning python and I have a doubt:

In python 2.6.x I usually declare encoding in the file header like this (as in PEP 0263)

# -*- coding:         


        
5条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-27 11:35

    The header definition is to define the encoding of the code itself, not the resulting strings at runtime.

    putting a non-ascii character like ۲ in the python script without the utf-8 header definition will throw a warning

提交回复
热议问题