search

Home  >  Q&A  >  body text

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

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

为什么很多写法

巴扎黑巴扎黑2802 days ago860

reply all(5)I'll reply

  • 阿神

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

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

    reply
    0
  • PHP中文网

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

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

    reply
    0
  • 怪我咯

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

    Described in https://www.python.org/dev/pe...
    pep0263. . .

    reply
    0
  • PHP中文网

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

    No need to write if you use python3! !

    reply
    0
  • 天蓬老师

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

    There are indeed many ways to write, the ones given by the questioner are all acceptable, the first two are more common

    But as long as it meets the following rules:

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

    Note: When writing, there are no spaces or tabs between coding and the equal sign and colon

    reply
    0
  • Cancelreply