我正在为吃角子老虎机游戏编写一个简单的脚本代码学院.com 我想把打印的东西放在同一个地方,第一次打印下的东西不全是前一次。这可能吗?你知道吗
在我的脚本中,我打印出这样一块板:
slot = []
for row in range(9):
slot.append(['[]'] * 9)
def print_slot(slot):
for element in slot:
print(" ".join(element))
print_slot(slot)
在这个董事会之后,我不想每个动作都有另一个董事会 但是我希望操作发生在board中,或者更好的是,类似于重新运行代码时得到的输出。你知道吗
如何才能做到这一点?和印刷品不一样吗? 或者python控制台是这样工作的,一个完整的程序可以是不同的。(这里是真正的初学者)
这是我在用户输入之前的输出:
##- simple slotmachine -##
##- five identical win -##
##- u start with 100cr -##
[] [] [] [] [] [] [] [] []
[] [] [] [] [] [] [] [] []
[] [] [] [] [] [] [] [] []
[] [] [] [] [] [] [] [] []
[] [] [] [] [] [] [] [] []
[] [] [] [] [] [] [] [] []
[] [] [] [] [] [] [] [] []
[] [] [] [] [] [] [] [] []
[] [] [] [] [] [] [] [] []
##- simple slotmachine -##
##- five identical win -##
##- space enter 2 play -##
在用户输入之后:
##- simple slotmachine -##
##- five identical win -##
##- u start with 100cr -##
[] [] [] [] [] [] [] [] []
[] [] [] [] [] [] [] [] []
[] [] [] [] [] [] [] [] []
[] [] [] [] [] [] [] [] []
[] [] [] [] [] [] [] [] []
[] [] [] [] [] [] [] [] []
[] [] [] [] [] [] [] [] []
[] [] [] [] [] [] [] [] []
[] [] [] [] [] [] [] [] []
##- simple slotmachine -##
##- five identical win -##
##- space enter 2 play -##
[] [] [] [] [] [] [] [] []
[] [] [] [] [] [] [] [] []
[] [] [] [] [] [] [] [] []
[] [] [] [] [] [] [] [] []
[] [] 0 4 5 4 5 [] []
[] [] [] [] [] [] [] [] []
[] [] [] [] [] [] [] [] []
[] [] [] [] [] [] [] [] []
[] [] [] [] [] [] [] [] []
正如你所看到的以前的董事会仍然是可见的,我想更换一个新的董事会在每一个变化。你知道吗
这是一个如何模拟
stdout
中旧行的重写的示例(实际上,您将使用\r
返回到行的开头,并重写旧输入):您可以使用these VT100 codes覆盖前面的行,如this answer所示:
相关问题 更多 >
编程相关推荐