gpt4 book ai didi

python - 在 Python 2.6 中将回车符返回到 0,0

转载 作者:行者123 更新时间:2023-11-30 23:45:22 26 4
gpt4 key购买 nike

我正在尝试显示一个网格,其中包含移动的个体。目前我使用“清晰屏幕”然后显示网格。这很困惑,因为屏幕每次都会“闪烁”。

在 C 和 VB.NET 中,有一些方法可以强制回车返回控制台的开头并覆盖内容。这消除了闪烁。

Python 可以做到这一点吗?我用 Google 搜索了一下,找到了 Curses,但那只是 Unix(我将主要在 Windows 中工作)。

当前网格代码( super 基本):

#Clear() is a OS indepedent method of clearing the screen defined in code above, in windows its just os.system('cls')
clear()
x=0
y=0
tiles=""
tile=""
# Generate grid
while(y<max_y):
while(x<max_x):
tile = tileGen(x,y)
tiles += str(tile)
x+=1
tiles += "\n"
y+=1
x=0
print(tiles)

最佳答案

也许这会有所帮助:ANSI Escape Sequences

Home 命令将为'\x1b[0;0H'

关于python - 在 Python 2.6 中将回车符返回到 0,0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9552315/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com