도피 시퀀스에서 문자 형식 변경

의 목적


컬러 출력에는 특수 문자\033[93m가 사용됩니다.
그걸 다 외우기가 어려워서 통일된 코드를 썼어요.
저자는 alias colors='...'.bash_profile에 추기를 하면 불러낼 수 있다.

컨디션


python
$ python
Python 3.6.4 |Anaconda custom (64-bit)| (default, Jan 16 2018, 12:04:33)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

코드


color.py
#!/usr/bin/env python

for i in range(110):
    print(f'\033[{i}m' + '{0:3d}'.format(i) + '\033[0m', end = ' ')
    if str(i)[-1] == '9':
        print('\n')

실행



종결어.

좋은 웹페이지 즐겨찾기