bytes与str(encode,decode)
2018-09-09 13:13
295 查看
#str(文本Unicide) 与bytes(二进制字节)互相转换。。。。这是2个不同类型数据!!
goood="我 is 死的"
print(goood,type(goood))
print(goood.encode(encoding="utf-8"))#字符串str数据用encode转换成字节bytes数据
print(goood.encode(encoding="utf-8").decode("utf-8"))# bytes用decode转换成str
str # 是字符串
name="永不言败" #字符串类型
print(type(name))
print(name.encode())
print(name.encode().decode())
bytes # 是字节(字节只能包含ASCII文字字符)
name2=b'abcd'
print(type(name2))
print(name2.decode())
print(name2.decode().encode())
goood="我 is 死的"
print(goood,type(goood))
print(goood.encode(encoding="utf-8"))#字符串str数据用encode转换成字节bytes数据
print(goood.encode(encoding="utf-8").decode("utf-8"))# bytes用decode转换成str
str # 是字符串
name="永不言败" #字符串类型
print(type(name))
print(name.encode())
print(name.encode().decode())
bytes # 是字节(字节只能包含ASCII文字字符)
name2=b'abcd'
print(type(name2))
print(name2.decode())
print(name2.decode().encode())
相关文章推荐
- python3中bytes和str,encode和decode的区别
- python的str,unicode对象的encode和decode方法, Python中字符编码的总结和对比bytes和str
- python的str,unicode对象的encode和decode方法, Python中字符编码的总结和对比bytes和str
- python3 str.encode bytes.decode
- python蛋疼的编码decode、encode、unicode、str、byte的问题都在这了
- python的str,unicode对象的encode和decode方法(转)
- python的str,unicode对象的encode和decode方法
- python3 unicode bytes decode encode之间联系
- URLEncoder.encode(str,"编码") new URLDecoder().decode(str,"编码")
- python的str,unicode对象的encode和decode方法
- python的str,unicode对象的encode和decode方法
- python的str,unicode对象的encode和decode方法
- 字符串加密,解密,利用 sun.misc.BASE64Decode类的 encode(byte)编码和decodeBuffer(str)解码
- python的str,unicode对象的encode和decode方法(转)
- python Unicode与str decode与encode 中文输出
- 转:python的str,unicode对象的encode和decode方法
- python的str,unicode对象的encode和decode方法
- http get 请求地址传中文或值带特殊符号解决方法 URLEncoder.encode(str,"编码") new URLDecoder().decode(str,"编码")
- 浏览器地址传中文解决方法 URLEncoder.encode(str,"编码") new URLDecoder().decode(str,"编码")
- python的str,unicode对象的encode和decode方法(转)