python使用fileinput模块实现逐行读取文件的方法
本文实例讲述了python使用fileinput模块实现逐行读取文件的方法。分享给大家供大家参考。具体实现方法如下:
#-------------------------------- # Name: read_lines.py # Author: Kevin Harris # Last Modified: 02/13/04 # Description: This Python script demonstrates # how to use fileinput to read # each line of a given file. #-------------------------------- import fileinput for line in fileinput.input( "test.txt" ): print line, raw_input( '\n\nPress Enter to exit...' )
希望本文所述对大家的Python程序设计有所帮助。
相关推荐
idning 2020-02-14
hanxia 2020-06-01
蔷薇部落 2017-03-28
DreamPig 2019-06-27
一叶不知秋 2017-12-15
fuziwang 2017-06-30
Ninjajs 2017-06-06
CrazyDogWang 2016-11-08
wangpeng0 2018-06-22
小肖 2016-11-08
billbliss 2017-07-12
pythonpycharm 2017-07-11
pythonxuexi 2019-04-26
helen0 2019-04-24
Triagen 2019-04-20
lispython 2019-04-20
hbupig 2014-02-13
csssy00 2017-09-08
PythonGCS 2019-04-17