格式化字符串¶
格式化字符串 节点使用与 Python 兼容的字符串格式语法或 Blender 的格式指定符 语法将值插入字符串。
该节点简化了字符串的构造,无需将数字转换为字符串或使用多个连接节点,即可对数值进行组合与格式化。
See also
Python 语法参考:- Python 格式字符串语法 - {fmt} 格式字符串语法
输入¶
- 格式
A string using either python format style or Blender's format specifier. For example,
Count: {}inserts the first input value in place of the {}.
其他输入值(浮点数、整数或字符串)可在侧栏的格式化项目列表中进行管理。
属性¶
格式化项目¶
A list view. to manage the dynamic list of inputs used in the format string. Each entry corresponds to a value that can be inserted into the format using a placeholder. See Input Naming Behavior to understand how inputs must be named.
- 接口类型
该输入值的类型:
- 浮点:
浮点数(例如
3.14)。- 整数:
整数(例如
42)。- 字符串:
文本字符串。
输出¶
- 字符串
格式化的字符串。
注意¶
Supports both unnamed (
{}) and named ({name}) placeholders. However, all unnamed placeholders must appear before any named ones.Only float, integer, and string inputs are supported.
Python-style conversions such as
!rare not supported.Sub-attribute access (e.g.
{vector.x}) is not supported.Percent-based formatting (e.g.
%d,%s) is not supported.Alternate form specifiers using
#(e.g.{:#x}) are not supported.Locale-based formatting using
L(as in the fmt library) is not supported.Grouping options like thousands separators (e.g.
{:,}or{:_}) are not supported.
Input Naming Behavior¶
Each input must have a unique, valid identifier name used in placeholders (e.g. {value}).
This node uses special logic to automatically assign names to new inputs:
If connected, the first character of the linked socket's name is used.
Otherwise, names default to letters
athroughz.If needed, the original socket name is converted to a valid identifier.
If all else fails, a unique suffix is appended (e.g.
_001,_002).
Important
Input names must be valid identifiers and must be unique. If a name is invalid, the format operation may fail or produce incorrect output.
示例¶
基础¶
格式:
Count: {}输入:值为 5 的整数
结果:
Count: 5
多个值¶
格式:
X: {}, Y: {}输入:浮点数 1.5, 浮点数 2.0
结果:
X: 1.5, Y: 2.0
已命名的输入¶
格式:
Size: {width} x {height}输入:width=1920, height=1080
结果:
Size: 1920 x 1080
填充编号¶
格式:
Frame_{:04}输入:整数 12
结果:
Frame_0012
编号格式(模板样式)¶
格式:
##.00输入:浮点数 3.1415
结果:
03.14
带帧编号的路径¶
格式:
/output/image_{:04}.png输入:整数 42
结果:
/output/image_0042.png