5.2.2 字面值 Literals

Python supports string literals and various numeric literals:

Python支持字符串字面值和数值型字面值:

Download entire grammar as text.

Evaluation of a literal yields an object of the given type (string, integer, long integer, floating point number, complex number) with the given value. The value may be approximated in the case of floating point and imaginary (complex) literals. See section 2.4 for details.

使用一个字面值会得到一个具有给定值的相应类型的对象(字符串、整数、长整数、浮点数、复数),如果是浮点数和复数那么这个值可能是个近似值,详见2.4节。

All literals correspond to immutable data types, and hence the object's identity is less important than its value. Multiple evaluations of literals with the same value (either the same occurrence in the program text or a different occurrence) may obtain the same object or a different object with the same value.

所有字面值都属于不可变的数据类型,因此对象的标识比起它们的值来说显得次要一些。多次使用相同值的字面值(在程序代码中以相同形式出现或者以不同的形式出现)可能获得的是相同的对象或具有相同值的不同对象。