![]() |
|
[Python] Probably not possible but.. Colour changing in shell - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [Python] Probably not possible but.. Colour changing in shell (/showthread.php?tid=5599119) |
Probably not possible but.. Colour changing in shell - Skidy - Apr 13, 2017 So, in the Python shell is it possible to change specific print statements color? print("Hello") in red.. etc.. etc.. I only question this as I have seen a few things online but none seem to work Without installing some other library such as colorama. * - /usr - Apr 13, 2017 Hi, you should install some lib, like the one you stated (colorama) or termcolor. I've found this webpage which explain very well: since I've started learning python not so long ago, I'll paste the link here, because it can explain better than me ;) https://pypi.python.org/pypi/colorama In any case, on Windows, remember to import init, or it won't work. Hope you'll find a solution! * - systx - Apr 13, 2017 http://stackoverflow<.>com/questions/287871/print-in-terminal-with-colors-using-python PHP Code * - Skidy - Apr 13, 2017 (Apr 13, 2017 03:47 PM)systx Wrote: http://stackoverflow<.>com/questions/287871/print-in-terminal-with-colors-using-python That didn't work for some reason. I get this: Code [95mThis a color* - systx - Apr 13, 2017 (Apr 13, 2017 03:50 PM)Skidy Wrote: That didn't work for some reason. It only works on Linux and maybe mac not Windows. * - TheWarOwl - Apr 13, 2017 You can do it in the CMD shell, not the IDE shell. * - Pylon - Apr 13, 2017 If you are using the Terminal you can use this: PHP Code Hope this helps, Good luck! (Apr 13, 2017 04:07 PM)systx Wrote: It only works on Linux and maybe mac not Windows. Yes, this works on Macs OSX 👍 —————————————————————— If you want to learn Python, Join Me! ( #/96jKkqY ) How do you like my redneck signature? * - Goodies - Apr 13, 2017 Colorama is the way to go. It is available for both python 2 and 3. * - Skidy - Apr 14, 2017 (Apr 13, 2017 06:59 PM)Goodies Wrote: Colorama is the way to go. It is available for both python 2 and 3.Will it work in the IDE? * - ObliviousCore - Apr 14, 2017 PHP Code * - Skidy - May 1, 2017 (Apr 13, 2017 06:59 PM)Goodies Wrote: Colorama is the way to go. It is available for both python 2 and 3. Will this work for both mac and windows though? * - SIM-1866423 - May 2, 2017 (May 1, 2017 03:37 PM)Skidy Wrote: Will this work for both mac and windows though? "ANSI escape character sequences have long been used to produce colored terminal text and cursor positioning on Unix and Macs. Colorama makes this work on Windows, too, by wrapping stdout, stripping ANSI sequences it finds (which would appear as gobbledygook in the output), and converting them into the appropriate win32 calls to modify the state of the terminal. On other platforms, Colorama does nothing." https://github.com/tartley/colorama * - /usr - May 2, 2017 (May 1, 2017 03:37 PM)Skidy Wrote: Will this work for both mac and windows though? Yes, try using also termcolor, this sometimes is easier. * - Skidy - May 2, 2017 (May 2, 2017 03:35 AM)Mnemosyne Wrote: "ANSI escape character sequences have long been used to produce colored terminal text and cursor positioning on Unix and Macs. Colorama makes this work on Windows, too, by wrapping stdout, stripping ANSI sequences it finds (which would appear as gobbledygook in the output), and converting them into the appropriate win32 calls to modify the state of the terminal. On other platforms, Colorama does nothing." I read that shortly after making that post. Will close as this has been resolved. |