Directly on the code slightly. (python2.7)
#encoding =utf-8#author:walker#date:2014-11-18#function: Example python2 read UTF8 file (with special characters such as Chinese) import sys reload (SYS) Sys.setdefaultencoding (' UTF8 ') file = open (' Data.txt ', ' R ') print (' ******************************* ') for line in file: Print (Line.strip () encode (' GB18030 ') print ('-------------------------------') print (Line.strip ()) print (' ******* ') File.close ()
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/53/87/wKioL1RqoU3BCLbCAACkiVEOX6c450.jpg "title=" 111. JPG "alt=" wkiol1rqou3bclbcaackiveox6c450.jpg "/>
Tip: gb2312 < GBK < GB18030 (reference link)
Walker * 2014-11-18 * * *
This article is from "Walker's Journal" blog, please be sure to keep this source http://walkerqt.blog.51cto.com/1310630/1577735
Python2 Read UTF8 file (Chinese)