Created
December 6, 2021 01:22
-
-
Save x893675/49e31a101f78cd1195c86f425697a07d to your computer and use it in GitHub Desktop.
color print in console
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
/* | |
// 前景 背景 颜色 | |
// --------------------------------------- | |
// 30 40 黑色 | |
// 31 41 红色 | |
// 32 42 绿色 | |
// 33 43 黄色 | |
// 34 44 蓝色 | |
// 35 45 紫红色 | |
// 36 46 青蓝色 | |
// 37 47 白色 | |
// | |
// 代码 意义 | |
// ------------------------- | |
// 0 终端默认设置 | |
// 1 高亮显示 | |
// 4 使用下划线 | |
// 5 闪烁 | |
// 7 反白显示 | |
// 8 不可见 | |
fmt.Printf("\033[1;31;40m%s\033[0m\n","Red.") | |
*/ | |
func main() { | |
for b := 40; b <= 47; b++ { // 背景色彩 = 40-47 | |
for f := 30; f <= 37; f++ { // 前景色彩 = 30-37 | |
for d := range []int{0, 1, 4, 5, 7, 8} { // 显示方式 = 0,1,4,5,7,8 | |
fmt.Printf(" %c[%d;%d;%dm%s(f=%d,b=%d,d=%d)%c[0m ", 0x1B, d, b, f, "", f, b, d, 0x1B) | |
} | |
fmt.Println("") | |
} | |
fmt.Println("") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment