ansi代码只工作一次,但其他时间不工作-python

时间:2019-05-18 04:00:54

标签: python ansi-escape

我正在尝试制作显示文本的代码,返回到文本块的开头并显示不同的内容。

def melee_attack():
    melee1 = ('''      /| ________________
O|===|* >________________>
  \|''')
    melee2 = ('''_   _   _   _   /| ________________
_   _   _ O|===|* >________________>
_   _   _   _   \|''')

    print(melee1)
    time.sleep(1)
    sys.stdout.write("\033[F")
    sys.stdout.write("\033[F")
    sys.stdout.write("\033[F")
    print(melee2)
    time.sleep(1)
    sys.stdout.write("\033[F")
    sys.stdout.write("\033[F")
    sys.stdout.write("\033[F")
    print(melee1)
    time.sleep(.8)

这可以为弓箭和盾牌制作动画,但是出于某种原因,它会打印[?] [F而不是沿线向上移动。其他时候,我只是使用此功能复制并粘贴了它,所以我知道我的输入方式没有不同,这一次它不起作用。

0 个答案:

没有答案