简体   繁体   English

以下文字在 python 中的含义是什么?

[英]What the below literal means in python?

The literal values expressed in python as python 中的文字值表示为

'b"8.23"' and 'b"1.25"' 'b"8.23"' 和 'b"1.25"'

These are expressions specific to python.这些是特定于 python 的表达式。

The b character before a string produces a variable of byte type instead of string type.字符串前面的b字符产生一个byte类型的变量而不是string类型。 You may read about this definition on the official website .您可以在官方网站上阅读有关此定义的信息。

The character 'b' shows that the given variable is of type byte, not string.字符“b”表示给定变量的类型是字节,而不是字符串。

Let me distinguish between string and byte definitions to make it clear,让我区分字符串和字节定义以使其清楚,

str = '...' 
# Above literals is sequence of Unicode characters (Latin-1, UCS-2 or UCS-4)
bytes = b'...' 
# Above literals are sequence of octets (integers between 0 and 255)

) )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM