You could use the fileinput
module:
import fileinput
for line in fileinput.input():
pass
fileinput
will loop through all the lines in the input specified as file names given in command-line arguments, or the standard input if no arguments are provided.
Note: line
will contain a trailing newline; to remove it use line.rstrip()
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…