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

#file.py

#

#by ggt



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()

你可能感兴趣的:(python)