Python String format() Method
Python String format()
The format()
method formats strings contain "replacement fields" surrounded by curly braces {}.
Anything that is not contained in braces is considered literal text, which is copied unchanged to the output.
Note: If you need to include a brace character in the literal text, it can be escaped by doubling: {{ and }}.
Example
Output
Syntax
Parameter Values
Value | Type | Explanation |
---|---|---|
value1, value2, ... | Required | Specifies one or more values that should be formatted and inserted in the string. |
Return Value
Value | Explanation |
---|---|
String | Returns the formatted string. |
More Examples
In the following example, we will use different placeholder values:
Example
Output
Reminder
Hi Developers, we almost covered 90% of String functions and Interview Question on Python with examples for quick and easy learning.
We are working to cover every Single Concept in Python.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.