zoukankan      html  css  js  c++  java
  • python文件编码说明 coding

    权威来源:http://www.python.org/dev/peps/pep-0263/
    Python源文件的头部声明(声明在文件的第一行或第二行)

    # coding=utf-8

    # coding:utf-8

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

    要符合正则规范"coding[:=]s*([-w.]+)"  注意 :或=前后没有空格

    Defining the Encoding

        Python will default to ASCII as standard encoding if no other
        encoding hints are given.
    
        To define a source code encoding, a magic comment must
        be placed into the source files either as first or second
        line in the file, such as:
    
              # coding=<encoding name>
    
        or (using formats recognized by popular editors)
    
              #!/usr/bin/python
              # -*- coding: <encoding name> -*-
    
        or
    
              #!/usr/bin/python
              # vim: set fileencoding=<encoding name> :
    
        More precisely, the first or second line must match the regular
        expression "coding[:=]s*([-w.]+)". The first group of this
        expression is then interpreted as encoding name. If the encoding
        is unknown to Python, an error is raised during compilation. There
        must not be any Python statement on the line that contains the
        encoding declaration.

    PEP 的全名是 Python Enhancement Proposals, "Python 增強建議書" ,它是用來規範與定義 Python 的各種加強與延伸功能的技術規格。

    每個 PEP 都有一個編號而且是唯一的,這個編號一旦給定了就不會再改變,例如,PEP 3000 就是用來定義 Python 3.0 的相關技術規格,而 PEP 333 則是 Python 的 Web 應用程式介面 WSGI (Web Server Gateway Interface 1.0) 的規範

    關於 PEP 本身的相關規範是定義在 PEP 1,而所有的 PEP 列表則是在這裡

    Read more: http://www.arthurtoday.com/2009/11/python-pep.html#ixzz46oH9oBzV

    学习:http://blog.csdn.net/orangleliu/article/details/8755461

  • 相关阅读:
    .net Core自定义中间件中读取Request.Body和Response.Body的内容?
    团队项目的Git分支管理规范
    .net core2.2升级3.1
    .net core EF获取SQL
    EF 查询扩展
    IIS Express启动不了的的解决方案
    AutoMapper
    mssql 数据库“查询处理器用尽了内部资源,无法生成查询计划。”问题的处理
    微服务九大特性
    Flink入门
  • 原文地址:https://www.cnblogs.com/dennysong/p/5430502.html
Copyright © 2011-2022 走看看