Terminal-Farb-Referenz
ANSI-Farb-Escape-Code-Referenz und Vorschau für das Terminal.
Foreground Colors
| Preview | Escape Code | Code | |
|---|---|---|---|
| Black | \e[30m | FG: 30 | |
| Red | \e[31m | FG: 31 | |
| Green | \e[32m | FG: 32 | |
| Yellow | \e[33m | FG: 33 | |
| Blue | \e[34m | FG: 34 | |
| Magenta | \e[35m | FG: 35 | |
| Cyan | \e[36m | FG: 36 | |
| White | \e[37m | FG: 37 |
Bright/Bold
| Preview | Escape Code | Code | |
|---|---|---|---|
| Bright Black | \e[90m | FG: 90 | |
| Bright Red | \e[91m | FG: 91 | |
| Bright Green | \e[92m | FG: 92 | |
| Bright Yellow | \e[93m | FG: 93 | |
| Bright Blue | \e[94m | FG: 94 | |
| Bright Magenta | \e[95m | FG: 95 | |
| Bright Cyan | \e[96m | FG: 96 | |
| Bright White | \e[97m | FG: 97 |
Background Colors
| Preview | Escape Code | Code | |
|---|---|---|---|
| Black BG | \e[40m | BG: 40 | |
| Red BG | \e[41m | BG: 41 | |
| Green BG | \e[42m | BG: 42 | |
| Yellow BG | \e[43m | BG: 43 | |
| Blue BG | \e[44m | BG: 44 | |
| Magenta BG | \e[45m | BG: 45 | |
| Cyan BG | \e[46m | BG: 46 | |
| White BG | \e[47m | BG: 47 |
Text Styles
| Preview | Escape Code | Code | |
|---|---|---|---|
| Bold | \e[1m | 1 | |
| Dim | \e[2m | 2 | |
| Italic | \e[3m | 3 | |
| Underline | \e[4m | 4 | |
| Blink | \e[5m | 5 | |
| Reverse | \e[7m | 7 |
Custom Escape Code Builder
Output
\e[32mHello, World!\e[0mHäufig gestellte Fragen
Code-Implementierung
# ANSI terminal colors in Python
import sys
# Basic colors
RED = '\033[31m'
GREEN = '\033[32m'
YELLOW = '\033[33m'
BLUE = '\033[34m'
RESET = '\033[0m'
BOLD = '\033[1m'
print(f"{RED}Error: Something went wrong{RESET}")
print(f"{GREEN}Success: Operation completed{RESET}")
print(f"{YELLOW}Warning: Check your input{RESET}")
print(f"{BOLD}{BLUE}Info: Starting process...{RESET}")
# Cross-platform (use colorama for Windows support)
# pip install colorama
try:
from colorama import Fore, Back, Style, init
init(autoreset=True)
print(Fore.RED + 'Red text')
print(Back.GREEN + Fore.BLACK + 'Green background')
print(Style.BRIGHT + 'Bold text')
except ImportError:
# Fallback to direct ANSI codes
print('\033[31mRed text\033[0m')
Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.