且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Python 初学者 - 如何自定义输出窗口

更新时间:2022-11-19 23:24:19

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: