a="hello" c=a.encode(encoding=‘utf-8‘) a = b‘hello‘ b="世界" b = b.encode(encoding=‘utf-8‘) print(a,b,c)
输出
b‘hello‘ b‘\xe4\xb8\x96\xe7\x95\x8c‘ b‘hello‘ [Program finished]
a=”hello”和b=”世界”编码成bytes类型
原文:https://www.cnblogs.com/sea-stream/p/11190571.html