What does a b prefix before a python string mean?(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.
这篇关于python字符串之前的b前缀是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:python字符串之前的b前缀是什么意思?
基础教程推荐
- 使 Python 脚本在 Windows 上运行而不指定“.py";延期 2022-01-01
- 使用Python匹配Stata加权xtil命令的确定方法? 2022-01-01
- 使用 Google App Engine (Python) 将文件上传到 Google Cloud Storage 2022-01-01
- 如何在Python中绘制多元函数? 2022-01-01
- 哪些 Python 包提供独立的事件系统? 2022-01-01
- 将 YAML 文件转换为 python dict 2022-01-01
- 如何在 Python 中检测文件是否为二进制(非文本)文 2022-01-01
- Python 的 List 是如何实现的? 2022-01-01
- 症状类型错误:无法确定关系的真值 2022-01-01
- 合并具有多索引的两个数据帧 2022-01-01