bytes与str的encode与decode

root
abc abc
  • 19 May

encode与decode

bys3 = b'Hello'
print(type(bys3))
bys2 = bytes("中国", encoding="UTF-8")

bys = '中国人民大学'.encode("gbk")
print("bys length=", len(bys))
for x in bys:
print(x)
s = bys.decode("gbk")
print(s)