本文介绍了Python colorama无法与输入配合使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么一开始它不起作用?
真正的原因是什么? –某些人可能想深入了解狮身人面像的源代码.)
今天终于让colorama可以工作了,并且在打印字符串时效果很好,但是当我尝试将colorama与输入配合使用时,我遇到了每个人似乎都遇到的常见错误.
Finally got colorama working today, and it works excellent when printing strings, but I got the common error everyone seems to get when I attempted to use colorama with input.
这是我的代码:
launch = input(Fore.GREEN + "Launch attack?(Y/N): ")输出屏幕截图:
推荐答案
在我的系统上,input()使用 if 添加的颜色
On my system, input() works with colors if you add
import sphinx.quickstart到您的模块.
这是完整的代码.
from colorama import Fore import colorama import sphinx.quickstart colorama.init() launch = input(Fore.GREEN + "Launch attack? (Y/N): ")(这导致两个问题:
N.B.如果您通过 Git Bash 中的winpty运行python,请设置convert.
N.B. if you run python via winpty from Git Bash, set convert.
colorama.init(convert=True)否则,当前版本不会显示颜色.
Otherwise, you do not get color with the current versions.
更多推荐
Python colorama无法与输入配合使用?
发布评论