How to read a single character from the user?

后端 未结 23 3242
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-21 04:28

Is there a way of reading one single character from the user input? For instance, they press one key at the terminal and it is returned (sort of like getch()).

23条回答
  •  孤城傲影
    2020-11-21 05:14

    The build-in raw_input should help.

    for i in range(3):
        print ("So much work to do!")
    k = raw_input("Press any key to continue...")
    print ("Ok, back to work.")
    

提交回复
热议问题