知识卡片
文本与字节需明确编码边界
str表示Unicode文本,bytes表示0到255的字节序列,编码与解码把二者连接。非ASCII字符的字节数依编码而变,文件是否二进制打开由格式与加载API决定;不是所有旧CSV都必须二进制读取。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- · 查看原书依据
B.2.1 String types: str and bytes Strings (str) are sequences of Unicode characters. If you use a non-ASCII character in a str, it may contain multiple bytes for some of the characters. Non-ASCII characters pop up a lot if you are copying and pasting from the internet into your Python console or program. Some of them are hard to spot, like those curly asymmetrical quote
参考来源
- 位置:《Natural Language Processing in Action, Second Edition》附录B《附录B:Python与正则表达式》(来源项目:a19c7933-4eda-4176-aebd-30fe7e1ad292;源文件:extracted/Natural Language Processing in Action, Second Edition/_epub-src/OEBPS/Text/appendix-b.html)
- 结论依据:摘录中关于文本与字节需明确编码边界的定义、比较或条件支撑卡片;原书表述不严谨的范围已在覆盖记录逐项限定,不把案例结果外推为普遍结论。
- 原始内容:B.2.1 String types: str and bytes Strings (str) are sequences of Unicode characters. If you use a non-ASCII character in a str, it may contain multiple bytes for some of the characters. Non-ASCII characters pop up a lot if you are copying and pasting from the internet into your Python console or program. Some of them are hard to spot, like those curly asymmetrical quote