How to do “hit any key” in python?

后端 未结 7 1827
予麋鹿
予麋鹿 2020-12-01 09:00

How would I do a \"hit any key\" (or grab a menu option) in Python?

  • raw_input requires you hit return.
  • Windows msvcrt has getch() and getche().
  • <
7条回答
  •  [愿得一人]
    2020-12-01 09:47

    try:
      os.system('pause')  #windows, doesn't require enter
    except whatever_it_is:
      os.system('read -p "Press any key to continue"') #linux
    

提交回复
热议问题