python读文件

感谢以下链接:
http://www.cnblogs.com/blogCblog/p/5597574.html
http://www.cnblogs.com/allenblogs/archive/2010/09/13/1824842.html

# -*- coding: utf-8 -*-
import traceback 

file=open(u'readFile.py')
try:
    text=file.read()#读取全部文件
    print text.decode('utf-8')

    #lineList=file.readlines()#读取所有行,返回的是列表,将每一行封装到列表中
    #for line in lineList:
    #    print line.decode('utf-8')
except Exception ,e:
    print Exception,u":",e
finally:
    file.close()

原文出处:/show_1C7eCCJB8A3.html