Python 中str 与 bytes 数据结构转换

共同点,二者都是表示字符串的一种方式; 在python语法中,可以类似列表的下表进行访问、迭代器迭代,但是都不可以更改。

str -> bytes:

    bytes(str_instance, encoding='utf-8')

    str_instance.encode('utf-8')

bytes -> str:

 

posted on 2021-05-10 20:37  兵者  阅读(180)  评论(0编辑  收藏  举报

导航