ANSI转义序列
来源:互联网 发布:免费网张东伟网络诈骗 编辑:程序博客网 时间:2024/06/07 11:40
ANSI转义序列
转义是当由于技术等原因、无法直接在代码中写出所要的字符时采用的,以多个字符的有序组合来表示原本需要的字符的手段,而转义序列(英语:escape sequence)指在转义时使用的有序字符组合。
转译字符
有些字符具有特殊含义,必须特殊对待。
常见的转译字符
\n 換行符號
\r 回行符號
\t 定位 tab 符號
\f 跳頁
\b 退格
\a 鈴聲
\0 八進位數,如:\007
\x 十六進位數,如:\x16
\ \ 這個符號
\” ” 雙引號
用”\r”举例
s = "12345"print s # 12345r = "123\r45"print r # 453,在\r处跳转到行首
转译序列
ANSI sequences generally 通常格式为:
ESC [ ; …
转译说明
ESC [ 0 m # reset all (colors and brightness)
ESC [ 1 m # bright
ESC [ 2 m # dim (looks same as normal brightness)
ESC [ 22 m # normal brightnessFOREGROUND:
ESC [ 30 m # black
ESC [ 31 m # red
ESC [ 32 m # green
ESC [ 33 m # yellow
ESC [ 34 m # blue
ESC [ 35 m # magenta
ESC [ 36 m # cyan
ESC [ 37 m # white
ESC [ 39 m # resetBACKGROUND
ESC [ 40 m # black
ESC [ 41 m # red
ESC [ 42 m # green
ESC [ 43 m # yellow
ESC [ 44 m # blue
ESC [ 45 m # magenta
ESC [ 46 m # cyan
ESC [ 47 m # white
ESC [ 49 m # resetcursor positioning
ESC [ y;x H # position cursor at x across, y down
ESC [ y;x f # position cursor at x across, y down
ESC [ n A # move cursor n lines up
ESC [ n B # move cursor n lines down
ESC [ n C # move cursor n characters forward
ESC [ n D # move cursor n characters backwardclear the screen
ESC [ mode J # clear the screen
clear the line
ESC [ mode K # clear the line
这里ESC可以用16进制\x1b表示,也可以用8进制\033表示。
s = "hello world\r\x1b[Kansi"print s #ansi,跳转到行首,然后清理一行
相关博文
https://jcastellssala.com/2012/07/20/python-command-line-waiting-feedback-and-some-background-on-why/
http://www.jianshu.com/p/a924a6d6ed22
- ANSI转义序列
- 2. 什么是ANSI转义序列
- 11. 其他的非标准ANSI转义序列
- 转义序列
- JavaScript转义序列/转义字符
- ANSI C语言中的全部转义字符
- java中的转义序列
- C中的转义序列
- C# 转义字符序列
- HTML中的转义序列
- 转义字符序列
- C转义序列
- 字符转义序列
- JavaScript的转义序列
- char中的转义序列
- C转义序列
- C语言-转义序列
- C++ 中的转义序列
- c++实验3-个人所得税计算器
- 网站架构
- Fork/Join框架
- spring boot mybatis整合
- form表单中常用对象
- ANSI转义序列
- Python 处理时间差
- SQL批量删除数据
- iOS-时间戳转String
- c++实验3【个人所得税计算器】
- c#MD5字符串加密
- 去掉UINavigationBar底部的分割线
- 牛客网 前端编程题小结
- 实现Recovery形式本地化显示文本定制(recovery_l10n工具的使用