utf-8 和 gbk 编码下 中英文分别占几个字节
#编码下英文和中文分别占几个字节 s=""" gbk utf-8 "%s" %s %s "%s" %s %s "%s" %s %s """%("我",len("我".encode("gbk")),len("我".encode("gbk")), "l",len("l".encode("gbk")),len("l".encode("gbk")), ".",len(".".encode("gbk")),len(".".encode("gbk"))) print(s) #效果如下 """ gbk utf-8 "我" 2 2 "l" 1 1 "." 1 1 """
-----------------------------------------------------------------------------------------------------------------------------------------