Linux教程網
Python:按行輸出文件內容
- #! /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))
Copyright ©
Linux教程網 All Rights Reserved