8000 Go fmt.Print 格式化参数 · Issue #66 · git-zjx/git-zjx.github.io · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Go fmt.Print 格式化参数 #66
Open
@git-zjx

Description

@git-zjx

%v 输出结构体 {10 30}
%+v 输出结构体显示字段名 {one:10 tow:30}
%#v 输出结构体源代码片段 main.Point{one:10, tow:30}
%T 输出值的类型 main.Point
%t 输出格式化布尔值 true
%d 输出标准的十进制格式化 100
%b 输出标准的二进制格式化 99 对应 1100011
%c 输出定整数的对应字符 99 对应 c
%x 输出十六进制编码 99 对应 63
%f 输出十进制格式化 99 对应 63
%e 输出科学技科学记数法表示形式 123400000.0 对应 1.234000e+08
%E 输出科学技科学记数法表示形式 123400000.0 对应 1.234000e+08
%s 进行基本的字符串输出 ""string"" 对应 "string"
%q 源代码中那样带有双引号的输出 ""string"" 对应 ""string""
%p 输出一个指针的值 &jgt 对应 0xc00004a090
% 后面使用数字来控制输出宽度 默认结果使用右对齐并且通过空格来填充空白部分
%2.2f 指定浮点型的输出宽度 1.2 对应 1.20
%*2.2f 指定浮点型的输出宽度对齐,使用 - 标志 1.2 对应 *1.20

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0