{"Entry":{"collection":"func","key":"format","name":"format","aliases":[],"metadata":{"changed_in":["9.3"],"changes":[{"descriptions_changed":false,"doc_overhaul":false,"from":"9.0","group_changed":null,"signatures":{"added":[],"removed":[]},"status":"added","to":"9.1"},{"descriptions_changed":true,"doc_overhaul":false,"from":"9.2","group_changed":null,"signatures":{"added":["format ( formatstr text [, formatarg \"any\" [, ...] ] ) → text","format(formatstr text [, formatarg \"any\" [, ...] ])"],"removed":["format ( formatstr text [, str \"any\" [, ...] ] ) → text"]},"status":"changed","to":"9.3"},{"descriptions_changed":false,"doc_overhaul":true,"from":"12","group_changed":null,"signatures":{"added":[],"removed":[]},"status":"changed","to":"13"}],"content_hash":"0d9b21c13a7c87b13ef55c3dab0648487455226906e6be5f3b5c4011b1423911","first_version":"9.1","group":"string","group_label":"String Functions And Operators","groups":["string"],"imported_at":"2026-09-14T21:49:48.647326+08:00","last_version":"20","name":"format","name_key":"format","position":3009,"present_in":["9.1","9.2","9.3","9.4","9.5","9.6","10","11","12","13","14","15","16","17","18","19","20"],"signature":"format ( formatstr text [, formatarg \"any\" [, ...] ] ) → text","signature_count":2,"slug":"format","source_rev":"2026-09-14T13:14:25.684213+00:00@99e6866c","summary":"Formats arguments according to a format string; see Section 9.4.1.","summary_zh":""}},"Definition":{"Collection":"func","Key":"format","SourceDatabase":"center","Version":"18","SourceTable":"func","SourceKey":"format","SourceRevision":"2026-09-14T13:14:25.684213+00:00@99e6866c","Facts":{"description":"Formats arguments according to a format string; see Section 9.4.1. This function is similar to the C function sprintf.","description_html":"Formats arguments according to a format string; see \u003ca href=\"/docs/18/functions-string.html#FUNCTIONS-STRING-FORMAT\" title=\"9.4.1. format\"\u003eSection 9.4.1\u003c/a\u003e. This function is similar to the C function \u003ccode class=\"function\"\u003esprintf\u003c/code\u003e.","description_zh":"","description_zh_html":"","doc":{"anchor":"FUNCTIONS-STRING-OTHER","file":"functions-string.html","slug":"18"},"group":"string","group_label":"String Functions And Operators","lang":"en","layout":"table-new","pages":["functions-string.html"],"prose_only":false,"signatures":[{"description":"Formats arguments according to a format string; see Section 9.4.1. This function is similar to the C function sprintf.","description_html":"Formats arguments according to a format string; see \u003ca href=\"/docs/18/functions-string.html#FUNCTIONS-STRING-FORMAT\" title=\"9.4.1. format\"\u003eSection 9.4.1\u003c/a\u003e. This function is similar to the C function \u003ccode class=\"function\"\u003esprintf\u003c/code\u003e.","description_zh":"","description_zh_html":"","examples":[{"expr":"format('Hello %s, %1$s', 'World')","result":"Hello World, World"}],"html":"\u003ccode class=\"function\"\u003eformat\u003c/code\u003e ( \u003cem class=\"parameter\"\u003e\u003ccode\u003eformatstr\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003etext\u003c/code\u003e [\u003cspan class=\"optional\"\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003eformatarg\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003e\"any\"\u003c/code\u003e [\u003cspan class=\"optional\"\u003e, ...\u003c/span\u003e]\u003c/span\u003e ] ) → \u003ccode class=\"returnvalue\"\u003etext\u003c/code\u003e","returns":"text","text":"format ( formatstr text [, formatarg \"any\" [, ...] ] ) → text","zh_from":""},{"description":"formatstr is a format string that specifies how the result should be formatted. Text in the format string is copied directly to the result, except where format specifiers are used. Format specifiers act as placeholders in the string, defining how subsequent function arguments should be formatted and inserted into the result. Each formatarg argument is converted to text according to the usual output rules for its data type, and then formatted and inserted into the result string according to the format specifier(s).","description_html":"\u003cem class=\"parameter\"\u003e\u003ccode\u003eformatstr\u003c/code\u003e\u003c/em\u003e is a format string that specifies how the result should be formatted. Text in the format string is copied directly to the result, except where \u003cem class=\"firstterm\"\u003eformat specifiers\u003c/em\u003e are used. Format specifiers act as placeholders in the string, defining how subsequent function arguments should be formatted and inserted into the result. Each \u003cem class=\"parameter\"\u003e\u003ccode\u003eformatarg\u003c/code\u003e\u003c/em\u003e argument is converted to text according to the usual output rules for its data type, and then formatted and inserted into the result string according to the format specifier(s).","description_zh":"","description_zh_html":"","examples":[],"html":"\u003ccode class=\"function\"\u003eformat\u003c/code\u003e(\u003cem class=\"parameter\"\u003e\u003ccode\u003eformatstr\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003etext\u003c/code\u003e [\u003cspan class=\"optional\"\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003eformatarg\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003e\"any\"\u003c/code\u003e [\u003cspan class=\"optional\"\u003e, ...\u003c/span\u003e] \u003c/span\u003e])","returns":"","text":"format(formatstr text [, formatarg \"any\" [, ...] ])","zh_from":""}],"zh_from":""},"ManualEvidence":{"doc":{"anchor":"FUNCTIONS-STRING-OTHER","file":"functions-string.html","slug":"18"}},"MeasuredEvidence":{}},"Text":{"Collection":"func","Key":"format","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"format","Summary":"根据格式字符串对参数进行格式化；参见第 9.4.1 节。这个函数类似于C函数 sprintf。","BodyHTML":"根据格式字符串对参数进行格式化；参见\u003ca href=\"/docs/18/functions-string.html#FUNCTIONS-STRING-FORMAT\" rel=\"nofollow\"\u003e第 9.4.1 节\u003c/a\u003e。这个函数类似于C函数 \u003ccode\u003esprintf\u003c/code\u003e。\u003cpre\u003eformat ( formatstr text [, formatarg \u0026#34;any\u0026#34; [, ...] ] ) → text\u003c/pre\u003e根据格式字符串对参数进行格式化；参见\u003ca href=\"/docs/18/functions-string.html#FUNCTIONS-STRING-FORMAT\" rel=\"nofollow\"\u003e第 9.4.1 节\u003c/a\u003e。这个函数类似于C函数 \u003ccode\u003esprintf\u003c/code\u003e。\u003cpre\u003eformat(formatstr text [, formatarg \u0026#34;any\u0026#34; [, ...] ])\u003c/pre\u003e\u003cem\u003e\u003ccode\u003eformatstr\u003c/code\u003e\u003c/em\u003e是指定结果格式的字符串。格式字符串中的文本会直接复制到结果中，但\u003cem\u003e格式说明符\u003c/em\u003e所在的位置除外。格式说明符充当字符串中的占位符，定义如何格式化后续函数参数并将其插入结果。每个\u003cem\u003e\u003ccode\u003eformatarg\u003c/code\u003e\u003c/em\u003e参数都按照其数据类型通常的输出规则转换为文本，再根据格式说明符进行格式化并插入结果字符串。","SourceRevision":"1b5ca64c","ContentHash":"8d786cb34b588aecba7ecf6ef557dfcdec635151a2e77d11db8680a66701c743","Payload":{"description_zh":"根据格式字符串对参数进行格式化；参见第 9.4.1 节。这个函数类似于C函数 sprintf。","description_zh_html":"根据格式字符串对参数进行格式化；参见\u003ca href=\"/docs/18/functions-string.html#FUNCTIONS-STRING-FORMAT\" title=\"9.4.1. format\"\u003e第 9.4.1 节\u003c/a\u003e。这个函数类似于C函数 \u003ccode class=\"function\"\u003esprintf\u003c/code\u003e。","signatures":[{"description_zh":"根据格式字符串对参数进行格式化；参见第 9.4.1 节。这个函数类似于C函数 sprintf。","description_zh_html":"根据格式字符串对参数进行格式化；参见\u003ca href=\"/docs/18/functions-string.html#FUNCTIONS-STRING-FORMAT\" title=\"9.4.1. format\"\u003e第 9.4.1 节\u003c/a\u003e。这个函数类似于C函数 \u003ccode class=\"function\"\u003esprintf\u003c/code\u003e。","returns":"text","text":"format ( formatstr text [, formatarg \"any\" [, ...] ] ) → text","zh_from":"doc"},{"description_zh":"formatstr是指定结果格式的字符串。格式字符串中的文本会直接复制到结果中，但格式说明符所在的位置除外。格式说明符充当字符串中的占位符，定义如何格式化后续函数参数并将其插入结果。每个formatarg参数都按照其数据类型通常的输出规则转换为文本，再根据格式说明符进行格式化并插入结果字符串。","description_zh_html":"\u003cem class=\"parameter\"\u003e\u003ccode\u003eformatstr\u003c/code\u003e\u003c/em\u003e是指定结果格式的字符串。格式字符串中的文本会直接复制到结果中，但\u003cem class=\"firstterm\"\u003e格式说明符\u003c/em\u003e所在的位置除外。格式说明符充当字符串中的占位符，定义如何格式化后续函数参数并将其插入结果。每个\u003cem class=\"parameter\"\u003e\u003ccode\u003eformatarg\u003c/code\u003e\u003c/em\u003e参数都按照其数据类型通常的输出规则转换为文本，再根据格式说明符进行格式化并插入结果字符串。","returns":"","text":"format(formatstr text [, formatarg \"any\" [, ...] ])","zh_from":"doc"}],"zh_from":"doc"}},"RequestedLocale":"zh-Hans","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20","9.1","9.2","9.3","9.4","9.5","9.6"],"Locales":["en","zh-Hans"],"Signatures":[{"Version":"18","Ordinal":0,"Hash":"ae7ab52b804205e25de66d863b537e885eada8cc40e1f2a21f542128274c3f34","Text":"format ( formatstr text [, formatarg \"any\" [, ...] ] ) → text","Returns":"text","Payload":{"description":"Formats arguments according to a format string; see Section 9.4.1. This function is similar to the C function sprintf.","description_html":"Formats arguments according to a format string; see \u003ca href=\"/docs/18/functions-string.html#FUNCTIONS-STRING-FORMAT\" title=\"9.4.1. format\"\u003eSection 9.4.1\u003c/a\u003e. This function is similar to the C function \u003ccode class=\"function\"\u003esprintf\u003c/code\u003e.","description_zh":"","description_zh_html":"","examples":[{"expr":"format('Hello %s, %1$s', 'World')","result":"Hello World, World"}],"html":"\u003ccode class=\"function\"\u003eformat\u003c/code\u003e ( \u003cem class=\"parameter\"\u003e\u003ccode\u003eformatstr\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003etext\u003c/code\u003e [\u003cspan class=\"optional\"\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003eformatarg\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003e\"any\"\u003c/code\u003e [\u003cspan class=\"optional\"\u003e, ...\u003c/span\u003e]\u003c/span\u003e ] ) → \u003ccode class=\"returnvalue\"\u003etext\u003c/code\u003e","returns":"text","text":"format ( formatstr text [, formatarg \"any\" [, ...] ] ) → text","zh_from":""}},{"Version":"18","Ordinal":1,"Hash":"f25a0828b0aa052f811190b66294bb9ddbd9c00960f74dddf157df795bcbef10","Text":"format(formatstr text [, formatarg \"any\" [, ...] ])","Returns":"","Payload":{"description":"formatstr is a format string that specifies how the result should be formatted. Text in the format string is copied directly to the result, except where format specifiers are used. Format specifiers act as placeholders in the string, defining how subsequent function arguments should be formatted and inserted into the result. Each formatarg argument is converted to text according to the usual output rules for its data type, and then formatted and inserted into the result string according to the format specifier(s).","description_html":"\u003cem class=\"parameter\"\u003e\u003ccode\u003eformatstr\u003c/code\u003e\u003c/em\u003e is a format string that specifies how the result should be formatted. Text in the format string is copied directly to the result, except where \u003cem class=\"firstterm\"\u003eformat specifiers\u003c/em\u003e are used. Format specifiers act as placeholders in the string, defining how subsequent function arguments should be formatted and inserted into the result. Each \u003cem class=\"parameter\"\u003e\u003ccode\u003eformatarg\u003c/code\u003e\u003c/em\u003e argument is converted to text according to the usual output rules for its data type, and then formatted and inserted into the result string according to the format specifier(s).","description_zh":"","description_zh_html":"","examples":[],"html":"\u003ccode class=\"function\"\u003eformat\u003c/code\u003e(\u003cem class=\"parameter\"\u003e\u003ccode\u003eformatstr\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003etext\u003c/code\u003e [\u003cspan class=\"optional\"\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003eformatarg\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003e\"any\"\u003c/code\u003e [\u003cspan class=\"optional\"\u003e, ...\u003c/span\u003e] \u003c/span\u003e])","returns":"","text":"format(formatstr text [, formatarg \"any\" [, ...] ])","zh_from":""}}],"Spellings":null,"SQLState":null,"Evidence":null}
