【问题标题】:Is it superfluous to declare # -*- coding: utf-8 -*- after #!/usr/bin/python3? [duplicate]在#!/usr/bin/python3 之后声明# -*- coding: utf-8 -*- 是不是多余的? [复制]
【发布时间】:2016-11-24 08:17:14
【问题描述】:

我一直在写:

#!/usr/bin/python3
# -*- coding: utf-8 -*-

但我相信 Python3 默认使用 Unicode。

【问题讨论】:

    标签: python utf-8


    【解决方案1】:

    python3代码的默认编码utf-8。见python's unicode support

    如果您想在同一个文件中支持 python2.x,或者如果您想使用除 utf-8 之外的编码,则需要该注释,否则您可以不使用它而不会产生任何影响。

    【讨论】:

      猜你喜欢
      • 2020-10-18
      • 2022-01-12
      • 2022-08-02
      • 2017-05-31
      • 1970-01-01
      • 1970-01-01
      • 2014-08-05
      • 2019-08-08
      • 1970-01-01
      相关资源
      最近更新 更多