kbhit.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:speech_ml 作者: coopie 项目源码 文件源码
def getarrow(self):
        ''' Returns an arrow-key code after kbhit() has been called. Codes are
        0 : up
        1 : right
        2 : down
        3 : left
        Should not be called in the same program as getch().
        '''
        if os.name == 'nt':
            msvcrt.getch() # skip 0xE0
            c = msvcrt.getch()
            vals = [72, 77, 80, 75]
        else:
            c = sys.stdin.read(3)[2]
            vals = [65, 67, 66, 68]
        return vals.index(ord(c.decode('utf-8')))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号