# -*- coding: utf-8 -*-
bytes_object = b"example"
# str object
str_object = "example"
# 方法 (1)
# str转bytes
bytes(str_object, encoding = "utf8")
# bytes转str
str(bytes_object, encoding = "utf-8")
# 方法(2)
# str转bytes
str.encode(str_object)
# bytes转str
bytes.decode(bytes_object)
python之str与bytes互转
最新推荐文章于 2024-04-24 14:29:30 发布