Where does this come from: -*- coding: utf-8 -*-

前端 未结 4 1199
你的背包
你的背包 2020-11-30 17:29

Python recognizes the following as instruction which defines file\'s encoding:

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

I definitely saw this kind of instru

4条回答
  •  借酒劲吻你
    2020-11-30 17:48

    # -*- coding: utf-8 -*- is a Python 2 thing. In Python 3+, the default encoding of source files is already UTF-8 and that line is useless.

    See: Should I use encoding declaration in Python 3?

    pyupgrade is a tool you can run on your code to remove those comments and other no-longer-useful leftovers from Python 2, like having all your classes inherit from object.

提交回复
热议问题