Discuss / Python / a=’中文’ 这句执行之后,到底在内存中a的字节是什么样的

a=’中文’ 这句执行之后,到底在内存中a的字节是什么样的

TinyMin_21403

#1 Created at ... [Delete] [Delete and Lock User]

疑问:廖大大说在内存中统一使用unicode编码但是为什么 a=’中文’ a
打印出来的却是gbk的编码方式的字节流 '\xd6\xd0\xce\xc4'

而不是unicode的字节流 u'\u4e2d\u6587'

在内存中a=’中文’ 这句执行之后到底在内存中a的字节是什么样的

human_fans

#2 Created at ... [Delete] [Delete and Lock User]

存入是unicode 编码, 读出的化转成utf-8或者gbk吧。我是这么理解的


  • 1

Reply