它仅在 PyCharm 中以视觉方式工作
我正在编写一个电梯程序,我尝试像真正的电梯一样制作等待灯动画。但我想在之后打印一些输出,以便您可以在灯光动画开始之前看到整个电梯。
from termcolor import cprint
import time
# this would be user's input
level = 10
# ABOVE PART ELEVATOR
cprint(' ▲ ▼ ', 'yellow')
cprint(' ┏' + ('━' * 13) + '┓')
# LIGHTS
print(' ┃', end='')
for lights in range(1, 11):
cprint('⦿', 'yellow', end='', flush=True)
time.sleep(0.5)
print('┃')
# LOWER PART ELEVATOR
print(' ┣━━━━━━╥━━━━━━┫')
print(' ┃ ║ ┃\n' * 5 + ' ┃ ║ ┃')
print('━━━━┗━━━━━━╨━━━━━━┛━━━━')
print(f'\nYou have arrived at floor ', end='')
cprint(level, 'yellow')
所以这是一个像普通程序一样从左到右、从上到下打印的程序。但我希望输出是:
▲ ▼
┏━━━━━━━━━━━━━┓
┃ #lights ┃ <- animation appears after the entire elevator
┣━━━━━━╥━━━━━━┫
┃ ║ ┃
┃ ║ ┃
┃ ║ ┃
┃ ║ ┃
┃ ║ ┃
┃ ║ ┃
━━━━┗━━━━━━╨━━━━━━┛━━━━
"You have arrived at floor 10" <- this after lights
慕田峪9158850
侃侃尔雅
相关分类