0

What is the Python Equivalent of Batch's

PAUSE

function? The program shall wait for the user to press a key before continuation.

Moonicorn
  • 91
  • 1
  • 2
  • 9

1 Answers1

2

To pause for a few seconds, take a look at time.sleep.

To wait for input (you can discard it if you wish), use input or raw_input.

To wait for any input, this answer suggests (windows only):

import msvcrt as m
def wait():
    m.getch()

A following answer in the same thread suggests using an external tool if it's available (not windows), read:

os.system('read -s -n 1 -p "Press any key to continue..."')
Community
  • 1
  • 1
Reut Sharabani
  • 30,449
  • 6
  • 70
  • 88