剪刀石头布游戏的问题
在剪刀石头布的编辑程序时,已经玩了几轮如果不想和计算机继续玩下去,想按任意键退出这个程序,请问如何编辑
2020-10-29 13:40
程序代码:class _Getch:
"""Gets a single character from standard input. Does not echo to the screen."""
def __init__(self):
self.impl = _GetchWindows()
def __call__(self):
return self.impl()
class _GetchWindows:
def __init__(self):
import msvcrt
def __call__(self):
import msvcrt
return msvcrt.getch()
if __name__ == '__main__': # a little test
print ('Press a key')
inkey = _Getch()
import sys
for i in range(100):
k=inkey()
print ('you pressed ',k)
if k.decode()=='q':
break
2020-10-29 14:42
n=input("...") #输入你要值(引号里面)
if not(n=="石头" or n=="布" or n=="剪刀")
exit()
2021-01-25 17:15
2021-01-25 17:17
2021-02-01 09:57
2021-02-08 21:25
2021-07-12 13:09
2022-01-08 10:16