What does a b prefix before a python string mean?

前端 未结 2 2036
暖寄归人
暖寄归人 2020-11-22 14:19

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

2条回答
  •  旧巷少年郎
    2020-11-22 15:02

    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.

提交回复
热议问题