简体   繁体   English

colorama win32 调用对 win64 系统没有影响

[英]colorama win32 calls have no effect on a win64 system

on windows10 I have never been able to get colorama to work.在 windows10 上,我从来没有让 colorama 工作。 I am now on Python38 and colorama-0.4.4 I have checked that the ansitowin32 module is executing call_win32 but no color results.我现在使用 Python38 和 colorama-0.4.4 我检查了 ansitowin32 模块是否正在执行 call_win32 但没有颜色结果。 Is this because my windows is based on win64?这是因为我的windows是基于win64的吗? Here is my code and output: import colorama # Successfully installed colorama-0.4.4这是我的代码和 output: import colorama #成功安装 colorama-0.4.4

from colorama import Fore, Style
colorama.init(convert=True)   # to make windows calls for the escape sequences

print('default color')
print(f'{Fore.GREEN} in green {Style.RESET_ALL}.')


default color
 in green

The problem is your line 2问题是你的第 2 行

It will not run without import init它不会在没有 import init的情况下运行

from colorama import Fore, Style, init
init(convert=True)

print('default color')
print(f'{Fore.GREEN} in green {Style.RESET_ALL}.')

or this with import colorama :或者这个与import colorama

import colorama
colorama.init(convert=True)   

print('default color')
print(f'{colorama.Fore.GREEN} in green {colorama.Style.RESET_ALL}.')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM