我正在玩一些cmd/prompt动画/图形:
import os
import time
def printFrame(timeout, count):
os.system('cls')
l=0
while True:
for k in range(0,9):
for i in range(0,9):
for j in range(0,9):
if j == k and i != 4:
print("|", end="", flush=True)
elif j !=k and i == 4:
print("-", end="", flush=True)
elif j ==k and i == 4:
print("+", end="", flush=True)
else:
print("O", end="", flush=True)
print("")
time.sleep(timeout)
os.system('cls')
l += 1
if l > count:
break
if __name__ == "__main__":
printFrame(0.08, 2)
我想摆脱帧闪烁-特别是在第一行可见,我的想法是使用第二个打印线程:
def printFrame(timeout, count):
#print from example1
def printFrameTwo(timeout, count):
#print from example1 without os.system('cls')
if __name__ == "__main__":
p1 = threading.Thread(target = printFrame, args = (0.08, 2))
p2 = threading.Thread(target = printFrameTwo, args = (0.08, 2))
p1.start()
p2.start()
但效果相当令人失望-同步问题和第一行仍然非常闪烁,第二个想法是使用“预定义的帧”-但它不是很有教育意义-这里的好处是,我可以一次打印整行,但仍然效果不是预期的,第三个(最有希望的)想法是只改变必要的'像素'/字符中帧-但这里我需要在帧线之间移动!诅咒在windows上不起作用(至少在标准中不起作用)。你知道怎么咬吗?(windows,标准库)也许该如何加速操作系统('cls')'?你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐