raw_input in python without pressing enter

后端 未结 8 1578
情歌与酒
情歌与酒 2020-11-22 15:41

I\'m using raw_input in Python to interact with user in shell.

c = raw_input(\'Press s or n to continue:\')
if c.upper() == \'S\':
    print \'Y         


        
8条回答
  •  Happy的楠姐
    2020-11-22 16:14

    Instead of the msvcrt module you could also use WConio:

    >>> import WConio
    >>> ans = WConio.getkey()
    >>> ans
    'y'
    

提交回复
热议问题