【发布时间】:2011-08-18 22:13:57
【问题描述】:
我正在学习 Python 3.2 以进行基于文本的小冒险,以便练习并更加熟悉该语言。无论如何,我想让它在某些动作发生时,打印文本的颜色会发生变化。我该怎么做。
例如,我希望出现的第一个文本是:
if 'strength' in uniqueskill.lower():
time.sleep(3)
print('As you are a Warrior, I shall supply you with the most basic tools every Warrior needs.')
time.sleep(3)
print('A sword and shield.')
time.sleep(1)
print('You have gained A SWORD AND SHIELD!')
【问题讨论】:
-
您很可能需要输出 ANSI 转义序列,如 mentioned in this answer。