[oeasy]python0078_设置索引颜色_index_color_ansi_控制终端颜色
简介:
[oeasy]python0078_设置索引颜色_index_color_ansi_控制终端颜色
更多颜色
回忆上次内容
- 91-97 是 高亮 前景色
- 101-107是 高亮 背景色
![](https://ucc.alicdn.com/images/user-upload-01/img_convert/f58b089e8975b5591e6a1cff82e420d8.png?x-oss-process=image/resize,w_1400/format,webp)
更多颜色
![](https://ucc.alicdn.com/images/user-upload-01/img_convert/0606eb3c7b9a843af0afac3ace26e415.png?x-oss-process=image/resize,w_1400/format,webp)
索引颜色表
![](https://ucc.alicdn.com/images/user-upload-01/img_convert/1d972a95ad8dfea251dee7ed8e3f5677.png?x-oss-process=image/resize,w_1400/format,webp)
规则原理
![](https://ucc.alicdn.com/images/user-upload-01/img_convert/0093e2c0479bf6b0ab6ff6619771cbf2.png?x-oss-process=image/resize,w_1400/format,webp)
![](https://ucc.alicdn.com/images/user-upload-01/img_convert/1d972a95ad8dfea251dee7ed8e3f5677.png?x-oss-process=image/resize,w_1400/format,webp)
- r、g、b 都是从 {0,1,2,3,4,5} 的阶梯范围
- 具体的颜色数值
lolcat
![](https://ucc.alicdn.com/images/user-upload-01/img_convert/2f7e4607a98aa8e23e7a8bf1af6aebd1.png?x-oss-process=image/resize,w_1400/format,webp)
海蓝色的大海龟
![](https://ucc.alicdn.com/images/user-upload-01/img_convert/58226eae74db95ec3e730f6f38e23bbc.png?x-oss-process=image/resize,w_1400/format,webp)
![](https://ucc.alicdn.com/images/user-upload-01/img_convert/1ea0fecf482b77728656b886ae3a31f0.png?x-oss-process=image/resize,w_1400/format,webp)
循环范围
![](https://ucc.alicdn.com/images/user-upload-01/img_convert/1d972a95ad8dfea251dee7ed8e3f5677.png?x-oss-process=image/resize,w_1400/format,webp)
修改
![](https://ucc.alicdn.com/images/user-upload-01/img_convert/1d972a95ad8dfea251dee7ed8e3f5677.png?x-oss-process=image/resize,w_1400/format,webp)
![](https://ucc.alicdn.com/images/user-upload-01/img_convert/762375d61b16115f4eae282557eeb8f8.png?x-oss-process=image/resize,w_1400/format,webp)
![](https://ucc.alicdn.com/images/user-upload-01/img_convert/1dd34d15caa05febfd84e64094beaf4e.png?x-oss-process=image/resize,w_1400/format,webp)
设置前景 为 索引颜色
![](https://ucc.alicdn.com/images/user-upload-01/img_convert/98770bd162bce9ad1d597b73c1164002.png?x-oss-process=image/resize,w_1400/format,webp)
![](https://ucc.alicdn.com/images/user-upload-01/img_convert/9eed3fbcd24e34daf871b29b334d6352.png?x-oss-process=image/resize,w_1400/format,webp)
设置背景 为 索引颜色
![](https://ucc.alicdn.com/images/user-upload-01/img_convert/f08378a96a290c2c6aa63bcfe9c9ca0f.png?x-oss-process=image/resize,w_1400/format,webp)
![](https://ucc.alicdn.com/images/user-upload-01/img_convert/a9214d5e454a4be03c0fa58176d4cab2.png?x-oss-process=image/resize,w_1400/format,webp)
- 能否 让这些字 一个个出来 呢?
- 逐个出现 肯定要用到 延迟
一个个出来
![](https://ucc.alicdn.com/images/user-upload-01/img_convert/77cc418ee092f50fc25fa781185cabb8.png?x-oss-process=image/resize,w_1400/format,webp)
![](https://ucc.alicdn.com/images/user-upload-01/img_convert/fa82073cb9734a390ba01bc0e1fdd253.png?x-oss-process=image/resize,w_1400/format,webp)
设置
![](https://ucc.alicdn.com/images/user-upload-01/img_convert/1d972a95ad8dfea251dee7ed8e3f5677.png?x-oss-process=image/resize,w_1400/format,webp)
- 16 + 231 = 247
- 17 + 230 = 247
- 18 + 229 = 247
利用规律
![](https://ucc.alicdn.com/images/user-upload-01/img_convert/129f19c1d3881b4895f8d4534207c1d4.png?x-oss-process=image/resize,w_1400/format,webp)
![](https://ucc.alicdn.com/images/user-upload-01/img_convert/5e53d4b4fbb2a550ccd2a88b453e511e.png?x-oss-process=image/resize,w_1400/format,webp)
总结
- \33[38;5;XXXm 设置 前景为索引色
- \33[48;5;XXXm 设置 背景为索引色
![](https://ucc.alicdn.com/images/user-upload-01/img_convert/0e51b65569716a1e61d90d165115ea31.png?x-oss-process=image/resize,w_1400/format,webp)
- 有可能吗??🤔
- 我们下次再说!👋
- 蓝桥->https://www.lanqiao.cn/courses/3584
- github->https://github.com/overmind1980/oeasy-python-tutorial
- gitee->https://gitee.com/overmind1980/oeasypython
- 视频->https://www.bilibili.com/video/BV1CU4y1Z7gQ 作者:oeasy