colorama

Print several sentences with different colors

一笑奈何 提交于 2019-12-13 08:00:58
问题 I'm trying to print several sentences with different colors, but it won't work, I only got 2 colors, the normal blue and this red import sys from colorama import init, AnsiToWin32 stream = AnsiToWin32(sys.stderr).stream print(">>> This is red.", file=stream) 回答1: As discussed in the comments, change your code to use these features; import os, colorama from colorama import Fore,Style,Back colorama.init() print(Fore.RED + 'some red text') print(Back.GREEN + 'and with a green background') print

Colorama AssertionError in Python 3.2

拜拜、爱过 提交于 2019-12-10 23:03:53
问题 I've recently started using Python 3.2 and have never attempted programming before. I copied the colorama folder to the lib directory in C:\Python32\lib and then made the following code in my attempt at a text-based adventure game: import colorama from colorama import Fore, Back, Style colorama.init() notedaction = "You have gained a SWORD AND SHIELD!" uniqueskill = "strength" if 'strength' in uniqueskill.lower(): time.sleep(3) print('As you are a Warrior, I shall supply you with the most

How to apply coloring/formatting to the displayed text in input()-function (similar to print statement formatting)?

落爺英雄遲暮 提交于 2019-12-10 13:17:14
问题 I have a small game application, which is started from the Windows console (cmd.exe). I am able to format the text in any desired way using ANSI escape sequences. I would also love to apply formatting to the text from the input() -method, but I have not found a way how to do so. Here is the testing code... from colorama import init init(autoreset=True) RED = "\x1b[1;31;40m" print(f"{RED}This text is red\n") not_red = input(f"{RED}Insert some random stuff: ") in my windows console, you will

tqdm progressbar and colorama do not work together

荒凉一梦 提交于 2019-12-07 08:57:14
问题 I want to use colorama, but I already use tqdm in my code. Example: import colorama as color import tqdm as tqdm # without line it's working print(color.Fore.GREEN + 'Green text') It's working fine without tqdm, but if I import tqdm, colorama does not color the text until I restart the console. I use IPython console with Spyder (Python 3.6). Is there a way I can use these packages together? 回答1: try it as follow (https://github.com/tqdm/tqdm/issues/450) from tqdm import trange from colorama

Python colorama not working with input?

拥有回忆 提交于 2019-12-07 03:30:17
问题 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. Here's my code: launch = input(Fore.GREEN + "Launch attack?(Y/N): ") Screenshot of output: 回答1: On my system, input() works with colors if you add import sphinx.quickstart to your module. So here is the full code. from colorama import Fore import colorama import sphinx.quickstart colorama.init() launch = input(Fore

tqdm progressbar and colorama do not work together

我是研究僧i 提交于 2019-12-05 13:00:24
I want to use colorama, but I already use tqdm in my code. Example: import colorama as color import tqdm as tqdm # without line it's working print(color.Fore.GREEN + 'Green text') It's working fine without tqdm, but if I import tqdm, colorama does not color the text until I restart the console. I use IPython console with Spyder (Python 3.6). Is there a way I can use these packages together? Nàéèm try it as follow ( https://github.com/tqdm/tqdm/issues/450 ) from tqdm import trange from colorama import Fore for i in trange(int(7e7), bar_format="{l_bar}%s{bar}%s{r_bar}" % (Fore.GREEN, Fore.RESET)

Python colorama not working with input?

旧街凉风 提交于 2019-12-05 08:14:53
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. Here's my code: launch = input(Fore.GREEN + "Launch attack?(Y/N): ") Screenshot of output: On my system, input() works with colors if you add import sphinx.quickstart to your module. So here is the full code. from colorama import Fore import colorama import sphinx.quickstart colorama.init() launch = input(Fore.GREEN + "Launch attack? (Y/N): ") (This leads to two questions: Why does it not work in the first place? What is

Tee does not show output or write to file

拟墨画扇 提交于 2019-11-28 23:16:41
I wrote a python script to monitor the statuses of some network resources, an infinite pinger if you will. It pings the same 3 nodes forever until it receives a keyboard interrupt. I tried using tee to redirect the output of the program to a file, but it does not work: λ sudo ./pingster.py 15:43:33 node1 SUCESS | node2 SUCESS | node3 SUCESS 15:43:35 node1 SUCESS | node2 SUCESS | node3 SUCESS 15:43:36 node1 SUCESS | node2 SUCESS | node3 SUCESS 15:43:37 node1 SUCESS | node2 SUCESS | node3 SUCESS 15:43:38 node1 SUCESS | node2 SUCESS | node3 SUCESS ^CTraceback (most recent call last): File ".

Tee does not show output or write to file

核能气质少年 提交于 2019-11-27 14:36:25
问题 I wrote a python script to monitor the statuses of some network resources, an infinite pinger if you will. It pings the same 3 nodes forever until it receives a keyboard interrupt. I tried using tee to redirect the output of the program to a file, but it does not work: λ sudo ./pingster.py 15:43:33 node1 SUCESS | node2 SUCESS | node3 SUCESS 15:43:35 node1 SUCESS | node2 SUCESS | node3 SUCESS 15:43:36 node1 SUCESS | node2 SUCESS | node3 SUCESS 15:43:37 node1 SUCESS | node2 SUCESS | node3