Python字符串之Unicode
2016-06-19 00:00
232 查看
python3.0之后的字符串(str)都是以unicode形式存储
str和bytes之间需要以encode和decode方式转化
'中'.encode('utf8') #b'\xe4\xb8\xad'
b'\xe4\xb8\xad'.decode('utf8')
# -*- coding:utf-8 -*- #(必须出现在首行或第二行且首行必须为注释)用来告知编译器源文件中的字符采用的是utf-8编码
str和bytes之间需要以encode和decode方式转化
'中'.encode('utf8') #b'\xe4\xb8\xad'
b'\xe4\xb8\xad'.decode('utf8')
# -*- coding:utf-8 -*- #(必须出现在首行或第二行且首行必须为注释)用来告知编译器源文件中的字符采用的是utf-8编码
相关文章推荐
- python处理实时增量文件
- Ubuntu14.04 64位系统下安装python3.4对应的opencv3.0报错recompile with -fPIC 的解决办法
- Python 模块之os
- [lintcode the-smallest-difference]最小差(python)
- [Lintcode two-sum]两数之和(python,双指针)
- python _ underscore variable
- 【leetCode】Sum Root to Leaf Number python实现
- Python 简单爬虫实现(爬取百度百科信息)
- Python的上下文管理器
- python中的编码问题
- Python学习爬虫中遇到点问题
- 从0开始玩安全--Python篇--Python入门指导 & 案例Unixshadow密码破解
- 使用Python Pandas处理亿级数据
- 【leetCode】Path Sum II python实现
- python_day6学习笔记
- python之数据类型(二)
- [Python]垃圾回收机制
- python csv
- ubuntu上使用virtualenv建立多个python独立开发环境
- python之数据类型(一)