7C00.ME/houmu 2011-03-10

Python入门程序:文件操作和IO异常

#file.py
#

def main():
    try:
        filename = raw_input('Enter file name')
        fobj = open(filename,'r')
        for eachLine in fobj:
            print eachLine,
        fobj.close()
    except IOError,e:
        print 'file open error:',e

main()