PHP前端开发

python支持char吗

百变鹏仔 1个月前 (01-23) #Python
文章标签 python

python 之禅第三条
simple is better than complex.
在 python 中, string 中的每个字符占的空间大小是 8 bit。

>>> import sys>>> sys.getsizeof('')37>>> sys.getsizeof('a')38

可以看到, 空字符占用37个 byte, 长度为1的字符串 'a' 占内存 38个 byte. 多了一个字符 a 之后多了 1 个 byte。