How can I build a counter in python?

前端 未结 3 753
甜味超标
甜味超标 2021-01-24 20:09

I want to have it so that each time I hit the space bar, the number in the terminal increases by one, so that I can keep a number in my head and not forget it. However, if I use

3条回答
  •  不思量自难忘°
    2021-01-24 20:58

    import os
    
    while True:
        cmd = "read -n 1 c; print $c"
        key = os.popen(cmd).read()
        if key[0] == "z":
            x=x+1
            print x
    

提交回复
热议问题