github.com/GuanceCloud/cliutils@v1.1.21/pipeline/ptinput/funcs/md/strfmt.md (about) 1 ### `strfmt()` {#fn-strfmt} 2 3 函数原型:`fn strfmt(key, fmt: str, args ...: int|float|bool|str|list|map|nil)` 4 5 函数说明:对已提取 `arg1, arg2, ...` 指定的字段内容根据 `fmt` 进行格式化,并把格式化后的内容写入 `key` 字段中 6 7 函数参数 8 9 - `key`: 指定格式化后数据写入字段名 10 - `fmt`: 格式化字符串模板 11 - `args`:可变参数,可以是多个已提取的待格式化字段名 12 13 示例: 14 15 ```python 16 # 待处理数据:{"a":{"first":2.3,"second":2,"third":"abc","forth":true},"age":47} 17 18 # 处理脚本 19 json(_, a.second) 20 json(_, a.thrid) 21 cast(a.second, "int") 22 json(_, a.forth) 23 strfmt(bb, "%v %s %v", a.second, a.thrid, a.forth) 24 ```