Python 初学者 - 如何自定义输出窗口 [英] Python Beginner - How to customize the output window
问题描述
我是非编程背景的初学者.我正在使用 Windows 操作系统.每当我用 Python 编写程序并运行它时,它都会在 MS Dos 中打开并显示黑色屏幕.我只想更改背景和字体颜色.我该怎么做?
I am a beginner from a non programming background. I am using windows OS. Whenever I write a program in Python and run it, it opens in MS Dos with a black colored screen. I just want to change the background and the font color. How can I do that?
推荐答案
Windows 命令外壳非常有限,它不支持其他操作系统外壳支持的 ANSI 颜色代码.但我发现 colorama 模块对于在 Python 命令行界面中获取颜色非常有用.
The Windows command shell is pretty limited, it doesn't support the ANSI color codes that other OSes' shells do. But I found that the colorama module is extremely useful to get colors in Python command line interfaces.
来自上面链接的网站的示例:
Example from the website linked to above:
这是一个带有代码和输出的彩色 Hello World:
And here's a colorful Hello World with code and output:
这篇关于Python 初学者 - 如何自定义输出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!