我正在学习Python 3.2中的一个基于文本的小冒险,以便练习和熟悉这门语言。无论如何,我想这样做是为了当某些行为发生时,打印文本的颜色会发生变化。我该怎么做呢。在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转义序列,如[在此答复中提到(HTTP:// stackoverflow.com/questions/2330245/python-change-text-color-in-shell)。 – samplebias 2011-05-04 22:14:10