Pyhon:按行输出文件内容

 
#! /usr/bin/python3
try:
    filename = input('Please input filename:')
    fobj = open(filename,  'r')
    for eachLine in fobj:
        print(eachLine)
    fobj.close()
except IOError as err:
    print('file open error: {0}'.format(err))

你可能感兴趣的:(Pyhon:按行输出文件内容)