Update color/README.md

This commit is contained in:
2024-11-25 15:26:30 -05:00
parent bfc68488b2
commit 396a1adace

View File

@@ -1,5 +1,5 @@
```python
globals().update({color: lambda text, ansi=91+i: f'\x1b[{ansi}m{text}\x1b[0m'
for i, color in enumerate('red green yellow blue magenta cyan'.split())})
print(red('hello'), green('world'))
for i, color in enumerate('RGYBMC'):
globals()[color] = lambda text, i=i: f'\x1b[{91 + i}m{text}\x1b[0m'
print(R('hello'), G('world'))
```