15 lines
446 B
Markdown
15 lines
446 B
Markdown
```python
|
|
for i,x in enumerate('rgybmcRGYBMC'):globals()[x]=lambda s,i=i:f'\x1b[{31+i//6*60+i%6}m{s}\x1b[0m'
|
|
|
|
print(r('hello'), R('hello'))
|
|
|
|
|
|
def color(text, code=None):
|
|
if code: code = int(__import__('hashlib').sha1(code.encode()).hexdigest(), 16)
|
|
else: code = int(__import__('random').random() * 214)
|
|
return f'\x1b[38;5;{code % 214 + 17}m{text}\x1b[0m'
|
|
|
|
print(color('hello'))
|
|
print(color('world'))
|
|
print(color('fixed', 'fixed'))
|
|
``` |