-2

I want to know about how do I stop my python script after completing a process I'm running a .py script I want it to stop automatically after completing the 10th page. like I want to start it

pageIndex += 1

and want to stop it after completing it.

pageIndex >= 10
Mark Rowlands
  • 5,357
  • 2
  • 29
  • 41
Mark Zach
  • 25
  • 1
  • 7

1 Answers1

1

If you import the sys module, you can use the sys.exit() command at the point you wish to terminate your script. Something along the lines of:

if pageIndex >= 10:
    sys.exit()

It's worth noting that sys.exit() will terminate ALL running python scripts.

amitchone
  • 1,630
  • 3
  • 21
  • 45