{"id":20384334,"url":"https://github.com/gyakobo/python-colored-console-output","last_synced_at":"2025-03-04T23:13:06.324Z","repository":{"id":246841380,"uuid":"822277341","full_name":"Gyakobo/python-colored-console-output","owner":"Gyakobo","description":"This project showcases how to color code and output colored text on the console using Python.","archived":false,"fork":false,"pushed_at":"2024-07-01T00:09:44.000Z","size":4,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-15T08:07:09.294Z","etag":null,"topics":["color-coding","console","print","python3","stdout"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Gyakobo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-30T19:33:42.000Z","updated_at":"2024-12-03T18:10:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"0bf6224e-f568-4947-bdc3-7d63f382fbac","html_url":"https://github.com/Gyakobo/python-colored-console-output","commit_stats":null,"previous_names":["gyakobo/python-colored-console-output"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gyakobo%2Fpython-colored-console-output","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gyakobo%2Fpython-colored-console-output/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gyakobo%2Fpython-colored-console-output/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gyakobo%2Fpython-colored-console-output/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Gyakobo","download_url":"https://codeload.github.com/Gyakobo/python-colored-console-output/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241935269,"owners_count":20044827,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["color-coding","console","print","python3","stdout"],"created_at":"2024-11-15T02:27:23.116Z","updated_at":"2025-03-04T23:13:06.299Z","avatar_url":"https://github.com/Gyakobo.png","language":"Python","readme":"# Python Colored Console Output\r\n\r\n![image](https://img.shields.io/badge/Python-FFD43B?style=for-the-badge\u0026logo=python\u0026logoColor=blue)\r\n![image](https://img.shields.io/badge/windows%20terminal-4D4D4D?style=for-the-badge\u0026logo=windows%20terminal\u0026logoColor=white)\r\n\r\nAuthor: [Andrew Gyakobo](https://github.com/Gyakobo)\r\n\r\n## Intro\r\n\r\nIn Python, you can change the color of the text printed to the console by using ANSI escape sequences. These are special codes that can change the color and style of the terminal text.\r\n\r\n## Methodology\r\n\r\nHere is a simple example:\r\n\r\n```python\r\n# ANSI escape sequences for text colors\r\nRED = \"\\033[31m\"\r\nGREEN = \"\\033[32m\"\r\nYELLOW = \"\\033[33m\"\r\nBLUE = \"\\033[34m\"\r\nMAGENTA = \"\\033[35m\"\r\nCYAN = \"\\033[36m\"\r\nRESET = \"\\033[0m\"\r\n\r\n# Printing text in different colors\r\nprint(RED + \"This is red text\" + RESET)\r\nprint(GREEN + \"This is green text\" + RESET)\r\nprint(YELLOW + \"This is yellow text\" + RESET)\r\nprint(BLUE + \"This is blue text\" + RESET)\r\nprint(MAGENTA + \"This is magenta text\" + RESET)\r\nprint(CYAN + \"This is cyan text\" + RESET)\r\n```\r\n\r\nHere's a breakdown of the escape sequences:\r\n\r\n* `\\033[`: This is the escape character and the beginning of the ANSI code.\r\n* `31m, 32m, 33m, etc.`: These are the codes for different colors.\r\n* `0m`: This resets the text color to the default.\r\n\r\nThe colors available with these codes are:\r\n\r\n* 30: Black\r\n* 31: Red\r\n* 32: Green\r\n* 33: Yellow\r\n* 34: Blue\r\n* 35: Magenta\r\n* 36: Cyan\r\n* 37: White\r\n\r\nYou can also use libraries like colorama to make it easier to work with colored text, especially if you are writing cross-platform applications. Here's an example using colorama:\r\n\r\n```python\r\nfrom colorama import Fore, Style, init\r\n\r\n# Initialize colorama\r\ninit()\r\n\r\n# Printing text in different colors\r\nprint(Fore.RED + \"This is red text\" + Style.RESET_ALL)\r\nprint(Fore.GREEN + \"This is green text\" + Style.RESET_ALL)\r\nprint(Fore.YELLOW + \"This is yellow text\" + Style.RESET_ALL)\r\nprint(Fore.BLUE + \"This is blue text\" + Style.RESET_ALL)\r\nprint(Fore.MAGENTA + \"This is magenta text\" + Style.RESET_ALL)\r\nprint(Fore.CYAN + \"This is cyan text\" + Style.RESET_ALL)\r\n```\r\n`colorama` handles the reset for you, making it a bit easier to manage. To install `colorama`, you can use pip:\r\n\r\n```shell\r\n$ pip install colorama\r\n```\r\n\r\n## License\r\nMIT\r\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgyakobo%2Fpython-colored-console-output","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgyakobo%2Fpython-colored-console-output","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgyakobo%2Fpython-colored-console-output/lists"}