python decode和encode

encode:将其他字符类型转换为 bytes 类型对象

例子:

#字符串类型
str = "97kb.vip"  
#将字符串转化为 bytes 类型
str1 = str.encode('utf-8')

decode:将 bytes 类型对象转化为 str 类型

      例子:

# 最终得到的是一个字符串类型
str2 = str1.decode('utf-8')
posted @ 2018-07-25 03:30  不随。  阅读(2)  评论(0编辑  收藏  举报  来源