问题
I have written this:
while file.readline().startswith("#"):
continue
But I suspect the continue
is unnecessary? What is the correct syntax for what i'm trying to achieve?
回答1:
while file.readline().startswith("#"):
pass
This uses the pass statement :
The pass statement does nothing. It can be used when a statement is required syntactically but the program requires no action.
http://www.network-theory.co.uk/docs/pytut/passStatements.html
来源:https://stackoverflow.com/questions/14797046/python-syntax-for-an-empty-while-loop