Python: 'break' outside loop

前端 未结 5 1784
余生分开走
余生分开走 2020-12-01 01:42

in the following python code:

narg=len(sys.argv)
print \"@length arg= \", narg
if narg == 1:
        print \"@Usage: input_filename nelements nintervals\"
           


        
5条回答
  •  春和景丽
    2020-12-01 02:36

    Because break cannot be used to break out of an if - it can only break out of loops. That's the way Python (and most other languages) are specified to behave.

    What are you trying to do? Perhaps you should use sys.exit() or return instead?

提交回复
热议问题