python字符串之前的b前缀是什么意思?
问题描述
In a python source code I stumbled upon I've seen a small b before a string like in:
b"abcdef"
I know about the u
prefix signifying a unicode string, and the r
prefix for a raw string literal.
What does the b
stand for and in which kind of source code is it useful as it seems to be exactly like a plain string without any prefix?
This is Python3 bytes
literal. This prefix is absent in Python 2.5 and older (it is equivalent to a plain string of 2.x, while plain string of 3.x is equivalent to a literal with u
prefix in 2.x). In Python 2.6+ it is equivalent to a plain string, for compatibility with 3.x.
相关文章