Home > OS >  Exit a loop from terminal
Exit a loop from terminal

Time:11-09

I would like to know how to leave a loop from the terminal, otherwise when closing it...enter image description here

Thanks!

I tried 'exit', 'leave' and others keywords like that

CodePudding user response:

In Mac and Windows: control C. In general it terminate a process.

CodePudding user response:

try adding keyboard Interrupt exception

try:
    while True:
        pass
except KeyboardInterrupt, e:
    print "Stopped"
    raise
  • Related