要更改配色方案,请在中编辑[颜色]部分
config.txt。但是,您无法在程序执行期间执行此操作,即使您这样做,效率也非常低。您无需安装任何新模块。您可以通过
subprocessPython附带的模块来执行此操作。
就像是:
from subprocess import callcall('color a', shell=True) #this sets the color to light greenprint('The quick brown fox jumps over the lazy dog.')这适用于Windows,并且您可以根据操作系统轻松更改所调用的命令。对于您的程序,您可以将颜色
for循环放置,并根据
请注意,只有从文件位置或命令行运行它时,此方法才有效。当您在IDLE中运行它时,它将不起作用。希望我能帮上忙!
编辑: 您可以在这里找到颜色列表。语法为:
color 'background ID''text ID'。
这将使您可以执行以下操作:
import timefrom subprocess import callfor color in('a', 'e', 'c'): #cycles through different colours call('cls', shell=True) #clears the screen call('color ' + color, shell=True) print('The quick brown fox jumps over the lazy dog.') time.sleep(1)input("nPress enter to exit. ")由此,您可以修改代码以使用您选择的颜色。不幸的是,绝对不可能同时在屏幕上显示所有颜色。对于您 不要 需要外部模块,我害怕。



