ham*_*ene 123 python emacs encoding text file
Python将以下内容识别为定义文件编码的指令:
# -*- coding: utf-8 -*-
Run Code Online (Sandbox Code Playgroud)
我确实在(-*- var: value -*-
)之前看过这种指令.它从何而来?什么是完整的规范,例如,值可以包括空格,特殊符号,换行符,甚至-*-
本身?
我的程序将编写纯文本文件,我想使用这种格式在其中包含一些元数据.
And*_*ini 79
This way of specifying the encoding of a Python file comes from PEP 0263 - Defining Python Source Code Encodings.
It is also recognized by GNU Emacs (see Python Language Reference, 2.1.4 Encoding declarations), though I don't know if it was the first program to use that syntax.
Bor*_*ris 43
# -*- coding: utf-8 -*-
是 Python 2 的东西。在 Python 3+ 中,源文件的默认编码已经是 UTF-8,该行没有用。
pyupgrade
是一种可以在代码上运行的工具,用于从 Python 2 中删除那些注释和其他不再有用的剩余部分,例如让所有类都继承自object
.
归档时间: |
|
查看次数: |
83037 次 |
最近记录: |