Heim  >  Fragen und Antworten  >  Hauptteil

python3.x - python指定utf-8编码的标准写法是什么?

# -*- coding:utf-8 -*-
# coding=utf-8
# encoding: utf-8

为什么很多写法

巴扎黑巴扎黑2741 Tage vor834

Antworte allen(5)Ich werde antworten

  • 阿神

    阿神2017-04-18 10:17:58

    PEP0263:
    https://www.python.org/dev/pe...

    Antwort
    0
  • PHP中文网

    PHP中文网2017-04-18 10:17:58

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

    Antwort
    0
  • 怪我咯

    怪我咯2017-04-18 10:17:58

    https://www.python.org/dev/pe...
    pep0263中有描述。。。

    Antwort
    0
  • PHP中文网

    PHP中文网2017-04-18 10:17:58

    用python3不用写吧!!

    Antwort
    0
  • 天蓬老师

    天蓬老师2017-04-18 10:17:58

    写法确实有好多,题主给出的几个都可以,前两个比较常见

    但是只要符合下面这个正则即可:

    ^[ \t\v]*#.*?coding[:=][ \t]*([-_.a-zA-Z0-9]+)
    

    注意:写的时候coding和等号冒号中间没有空格或者制表符

    Antwort
    0
  • StornierenAntwort