1.str ==> bytes >>> s = 'abc' >>> s.encode() # 可以是s.encode('utf8')或者s.encode('ascii') b'abc' >>> bytes(s, encoding='utf8') b'abc' 2.bytes ==> str >>> b = b'abc' >>> b.decode() 'abc' >>> str(b, encoding = 'utf8') 'abc'