python str bytes转换
2016-06-04 19:10
429 查看
1. 构造str bytes
output:
<class 'str'>
<class 'bytes'>
2. 构造str bytes
<class 'str'>
<class 'bytes'>
3. str bytes 转换
<class 'str'>
<class 'bytes'>
4. str bytes 转换
<class 'str'>
<class 'bytes'>
str_var = 'hello world' bytes_var = b'hello world' print(type(str_var)) print(type(bytes_var))
output:
<class 'str'>
<class 'bytes'>
2. 构造str bytes
str_var = str('hello world') bytes_var = bytes('hello world', encoding = 'UTF8') print(type(str_var)) print(type(bytes_var))output:
<class 'str'>
<class 'bytes'>
3. str bytes 转换
str_var = b'hello world'.decode(encoding = 'UTF8') bytes_var = 'hello world'.encode(encoding = 'UTF8') print(type(str_var)) print(type(bytes_var))output:
<class 'str'>
<class 'bytes'>
4. str bytes 转换
str_var = str(b'hello world') bytes_var = bytes('hello world', encoding = 'UTF8') print(type(str_var)) print(type(bytes_var))output:
<class 'str'>
<class 'bytes'>
相关文章推荐
- Python进阶之函数式编程
- Python--详解Python中re.sub
- Opencv3.0-python的那些事儿:(四)、Opencv的图像阈值处理
- python学习第一天
- Python list 交集,并集,差集
- python学习 函数
- Python断行
- PYTHON 源码解析
- censys 数据库地理信息自定义接口(python版)
- python二叉树的层次遍历
- python之生成器
- 使用flask 发送电子邮件时候遇到的几个问题
- 使用python操作solr
- python爬虫:批量下载qq空间里的照片(一)
- Python logging模块
- Python Flask Web 第七课 —— 使用 flask-moment 本地化日期和时间
- [Lintcode 3sum]三数之和(python,二分)
- Python--基础学习--初识
- Python查看远程主机端口是否开放以及BashShell实现
- 素数生成器