简介
得到系统编码方式为 sys.getdefaultencoding(),默认为Unicode
python3的字符串编码类型有 bytes 、str 和可变的bytearray。
字符串相关
字符串编码方式
1.ord() 返回为ASCII码值
2.hex()返回为该数值的16进制
3.chr()返回为该ASCII数值对应的字符
Python字符串编码详解
本文深入探讨了Python3中字符串的编码方式,包括系统默认的Unicode编码,以及bytes、str和bytearray三种主要类型。详细讲解了ord()、hex()和chr()函数在字符串编码转换中的应用。
得到系统编码方式为 sys.getdefaultencoding(),默认为Unicode
python3的字符串编码类型有 bytes 、str 和可变的bytearray。
1.ord() 返回为ASCII码值
2.hex()返回为该数值的16进制
3.chr()返回为该ASCII数值对应的字符
1034
2675