main.py 文件源码

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

项目:OpenCLGA 作者: PyOCL 项目源码 文件源码
def get_input():
    global lines
    data = None
    try:
        if sys.platform in ['linux', 'darwin']:
            import select
            time.sleep(0.01)
            if select.select([sys.stdin], [], [], 0) == ([sys.stdin], [], []):
                data = sys.stdin.readline().rstrip()
        elif sys.platform == 'win32':
            import msvcrt
            time.sleep(0.01)
            if msvcrt.kbhit():
                data = msvcrt.getch().decode('utf-8')
                if data == '\r':
                    # Enter is pressed
                    data = lines
                    lines = ''
                else:
                    lines += data
                    print(data)
                    data = None
        else:
            pass
    except KeyboardInterrupt:
        data = 'exit'
    return data
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号