Trying to figure out how to write an if cycle to check if a line is empty.
The file has many strings, and one of these is a blank line to separate from the other statements (not a ""
; is a carriage return followed by another carriage return I think)
new statement
asdasdasd
asdasdasdasd
new statement
asdasdasdasd
asdasdasdasd
Since I am using the file input module, is there a way to check if a line is empty?
Using this code it seems to work, thanks everyone!
for line in x:
if line == '
':
print "found an end of line"
x.close()
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…