python 打印unicode字符串
来源:互联网 发布:网络贷款哪家能贷到 编辑:程序博客网 时间:2024/05/02 06:11
a=\u767e\u5ea6\u5728\u7ebf\u7f51\u7edc\u6280\u672f\uff08\u5317\u4eac\uff09\u6709\u9650\u516c\u53f8
>>> print unicode(a,'utf-8')
\u767e\u5ea6\u5728\u7ebf\u7f51\u7edc\u6280\u672f\uff08\u5317\u4eac\uff09\u6709\u9650\u516c\u53f8
>>> print(a.encode("utf-8").decode('unicode_escape'))
>>> print unicode(a,'utf-8')
\u767e\u5ea6\u5728\u7ebf\u7f51\u7edc\u6280\u672f\uff08\u5317\u4eac\uff09\u6709\u9650\u516c\u53f8
>>> print(a.encode("utf-8").decode('unicode_escape'))
百度在线网络技术(北京)有限公司
因此,在做编码转换时,通常需要以unicode作为中间编码,即先将其他编码的字符串解码(decode)成unicode,再从unicode编码(encode)成另一种编码。
decode的作用是将其他编码的字符串转换成unicode编码,
如str1.decode('gb2312'),表示将gb2312编码的字符串转换成unicode编码。
encode的作用是将unicode编码转换成其他编码的字符串,
如str2.encode('gb2312'),表示将unicode编码的字符串转换成gb2312编码。
a='养老保险'
b="{0}".format(a)
print b (显示 正常)
a=u'养老保险'
b="{0}".format(a)
print b (显示 "\u....")
u"{0"}.format(a) 则显示正常
0 0
- python 打印unicode字符串
- Python之打印Unicode列表
- python string unicode字符串
- Python中Unicode字符串
- Python中Unicode字符串
- Python中Unicode字符串
- Python中Unicode字符串
- Python中Unicode字符串
- Python中Unicode字符串
- python unicode字符串
- python unicode字符串
- python写的crond后台任务打印包含中文字符的unicode 字符串,出现异常?
- Python语言编写用多行Unicode字符串表示下面的唐诗’静夜思‘并打印
- Python2.7:打印字符串是Unicode
- python打印文档字符串
- Python判断Unicode字符串类型
- Python小记03 Unicode字符串
- python 中的unicode与字符串
- web Kohana_Exception [ 0 ]: Directory APPPATH/cache must be writable
- 蓝桥杯 入门训练 序列求和
- CGAffineTransform相关函数
- 通过Intent在Activity|Service之间传递数据
- js 格式化显示时间方法
- python 打印unicode字符串
- 人工智能
- SQLServer替换第一个匹配的字符串方法
- ArcMenu扇形菜单(底部)
- 服务性能监控都包括哪些指标?
- ie9中不开f12开发者工具,js失效问题
- 国内UED收录
- PLSQL Developer如何连接远程Oracle数据库
- 哈密顿图