001_020 Python 使用Unicode来处理国际化文本
2014-03-12 01:37
579 查看
代码如下:
打印结果如下:
中国
abc 中国
abc 中国
<type 'str'>
<type 'unicode'>
<type 'unicode'>
#encoding=utf-8 print '中国' #使用Unicode来处理国际化文本 #方案 编码转换ANSI为Unicode后处理 print 'abc 中国' print unicode('abc 中国') print type('abc') print type( unicode('abc 中国')) print type( 'abc'+ unicode('abc 中国')) #Python 默认转化方式 :ANSI + UNICODE = UNICODE #建议 读入写入外部文件(File web and so on)时候确定好编码 ,即IO操作的时候
打印结果如下:
中国
abc 中国
abc 中国
<type 'str'>
<type 'unicode'>
<type 'unicode'>
相关文章推荐
- 001_019 Python 检查字符串中的结束字符
- Python 异常处理实例详解
- Python 文件读写操作实例详解
- python文件和目录操作方法大全(含实例)
- 详解Python中的__init__和__new__
- Python面向对象3
- Python正则表达式指南
- 【Python】保留有效位
- python正则分组匹配小例
- virtualenv、pip备忘
- python 实现梯度下降
- python按行读取文件,如何去掉换行符"\n"
- Python核心编程——Chapter9
- Python核心编程——Chapter9
- Python调用win32api
- 《使用python进行自然语言理解》学习笔记二
- 使用 python Matplotlib 库绘图
- OpenCV Python 在Windows下的安装
- 安装python组件
- Non-ASCII character python文件中有中文编码出错 解决办法