Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?


printf() Function (Python, SLAX, and XSLT)


Python Syntax

SLAX Syntax

XSLT Syntax


Generate formatted output text. Most standard printf formats are supported, in addition to some Junos OS–specific formats. The function returns a formatted string but does not print it on call. To use the following Junos OS modifiers, place the modifier between the percent sign (%) and the conversion specifier.

  • j1—Operator that emits the field only if it changed from the last time the function was called. This assumes that the expression’s format string is unchanged.

  • jc—Operator that capitalizes the first letter of the associated output string.

  • jt{TAG}—Operator that emits the tag if the associated argument is not empty.

The prefix associated with the namespace URI should be defined in the prefix-to-namespace mapping in the style sheet.



Format string containing an arbitrary number of format specifiers and associated arguments to output.

Usage Examples

In the following example, the j1 operator suppresses printing the interface identifier so-0/0/0 in the second line of output, because the identifier argument has not changed from the first printing. The jc operator capitalizes the output strings up and down. The jt{--} operator does not print the {--} tag in the first line of output, because the associated output argument is an empty string. However, the tag is printed in the second line because the associated output is the non-empty string test.

produces the following output:

Release Information

Function introduced in Junos OS Release 7.6.

Support for the slax namespace added in Junos OS Release 12.2.

Support for Python added in Junos OS Release 16.1R1 on QFX Series switches and ACX Series, MX Series, PTX Series, and T Series routers.

Support for Python added in Junos OS Release 17.1R1 on ACX500, ACX1000, ACX1100, ACX2000, ACX2100, ACX2200, and ACX4000 routers, and EX Series switches.

Support for Python added in Junos OS Release 17.3R1 on SRX1500, SRX4100, SRX4200, SRX5400, SRX5600, and SRX5800 devices and vSRX instances.

Support for Python added in Junos OS Release 18.3R1 on ACX5048 and ACX5096 routers.