代码如下:
#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'>