'''(Tab)处缩进代码'''
from random import choice
def code():
(Tab)a = choice(lista)
(Tab)return a
if __name__ == "__main__":
(Tab)#print(code())
(Tab)while True:
(Tab)(Tab)gcode = code()
(Tab)(Tab)guess = input("输入0<石头>∣1<剪刀>〡2<布>:\t")
(Tab)(Tab)if (guess == "0" and gcode == "石头") or (guess == "1" and gcode == "剪刀") or (guess == "2" and gcode == "布"):
(Tab)(Tab)(Tab)print(f"right:{guess}=={gcode}")
(Tab)(Tab)(Tab)break
(Tab)(Tab)else:
(Tab)(Tab)(Tab)print(f"wrong:{guess}!={gcode}")
'''运行效果
输入0<石头>∣1<剪刀>〡2<布>: 1
wrong:1!=石头
输入0<石头>∣1<剪刀>〡2<布>: 0
wrong:0!=剪刀
输入0<石头>∣1<剪刀>〡2<布>: 2
wrong:2!=石头
输入0<石头>∣1<剪刀>〡2<布>: 1
right:1==剪刀
'''
文件夹之中,然后打开python编辑器来编写这个python文件的代码。在文件的顶部写上导入os模块的代码,然后创建一个无限的while循环。2.
在循环结构之中使用变量去保存几个字符串,字符串的内容就是python xxx.py。在循环的末尾使用os模块的system()并将一