Python 初学者 - 如何自定义输出窗口 [英] Python Beginner - How to customize the output window

查看:30
本文介绍了Python 初学者 - 如何自定义输出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是非编程背景的初学者.我正在使用 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆