How to do “hit any key” in python?

后端 未结 7 1836
予麋鹿
予麋鹿 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-01 09:44

    I implemented it like the following in Windows. getch() takes a one single character

    import msvcrt
    char = 0
    print 'Press any key to continue'
    while not char:
        char = msvcrt.getch()
    

提交回复
热议问题