如何在命令行的特定位置获取原始输入()

2024-04-16 18:58:36 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在做一个简单的游戏高分系统。 我使用“colorama”在命令行的特定位置打印文本。 如何在命令行的特定位置获取输入?你知道吗

score = 15
print '\033[10;20H{}'.format("Game over")
if score > 10:
    name = raw_input("Enter your name: ") #I want to get this in the position y = 11 , x = 20
    print '\033[12;12H{}'.format("Your score was added to high scores")

Tags: to命令行name文本gameformat游戏raw