It is a string formatting syntax (which it borrows from C).

Please see "PyFormat":

Python supports formatting values into strings. Although this can include very complicated expressions, the most basic usage is to insert values into a string with the %s placeholder.

Here is a really simple example:

#Python 2
name = raw_input("who are you? ")
print "hello %s" % (name,)

#Python 3+
name = input("who are you? ")
print("hello %s" % (name,))

The %s token allows me to insert (and potentially format) a string. Notice that the %s token is replaced by whatever I pass to the string after the % symbol. Notice also that I am using a tuple here as well (when you only have one string using a tuple is optional) to illustrate that multiple strings can be inserted and formatted in one statement.

Answer from Andrew Hare on Stack Overflow
🌐
freeCodeCamp
freecodecamp.org › news › python-string-format-python-s-print-format-example
Python String Format – Python S Print Format Example
August 11, 2024 - Here is the basic syntax: "This is a string %s" % "string value goes here" You can create strings and use %s inside that string which acts like a placeholder. Then you can write % followed be the actual string value you want to use.
🌐
GeeksforGeeks
geeksforgeeks.org › python › what-does-s-mean-in-a-python-format-string
What does %s mean in a Python format string? - GeeksforGeeks
July 23, 2025 - class Person: def __str__(self): return "Person object" obj = Person() message = "The object is: %s" % obj print(message) ... Even custom objects can be used with %s. Python automatically calls the __str__() method of the object to convert it ...
🌐
Python
docs.python.org › 3 › library › string.html
string — Common string operations
print() ... 5 5 5 101 6 6 6 110 7 7 7 111 8 8 10 1000 9 9 11 1001 10 A 12 1010 11 B 13 1011 ... The feature described here was introduced in Python 2.4; a simple templating method based upon regular expressions.
🌐
Learn Python
learnpython.org › en › String_Formatting
String Formatting - Learn Python - Free Interactive Python Tutorial
Any object which is not a string can be formatted using the %s operator as well. The string which returns from the "repr" method of that object is formatted as the string. For example: # This prints out: A list: [1, 2, 3] mylist = [1,2,3] print("A ...
Find elsewhere
🌐
W3Schools
w3schools.com › python › python_strings.asp
Python Strings
a = '''Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.''' print(a) Try it Yourself » · Note: in the result, the line breaks are inserted at the same position as in the code. Like many other popular programming languages, strings in Python are arrays of unicode characters.
🌐
Stuy
bert.stuy.edu › pbrooks › IntroResources › print_string_formatting.html
Print/string formatting
> pi=3.141592653 > last="Potter" ... string, enclose the variables inside parentheses: > print 'Official name: %s, %s' % (last,first) Official name: Potter, Harry > #### Use %f for floating point numbers (let Python choose the number of decimal places > print '%f' % pi 3.141593 ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-string
Python String - GeeksforGeeks
Python · s1 = 'GfG' s2 = "GfG" print(s1) print(s2) Output · GfG GfG · Use triple quotes ('''...''' ) or ( """...""") for strings that span multiple lines. Newlines are preserved. Example: Define and print multi-line strings using both styles. Python · s = """I am Learning Python String on GeeksforGeeks""" print(s) s = '''I'm a Geek''' print(s) Output ·
Published   March 28, 2026
🌐
PyFormat
pyformat.info
PyFormat: Using % and .format() for great good!
class Data(object): def __str__(self): return 'str' def __repr__(self): return 'repr' ... In Python 3 there exists an additional conversion flag that uses the output of repr(...) but uses ascii(...) instead.
🌐
Ohadravid
ohadravid.github.io › posts › 2026-02-go-sliced
Sliced by Go’s Slices
February 26, 2026 - // variadic expansion fmt.Printf("2 %v\n", nums) } func PrintSquares(nums ...int) { for i, n := range nums { nums[i] = n * n } fmt.Printf("1 %v\n", nums) } Answer (Playground): 1 [1 4 9] 2 [1 4 9] 🫠 · Meaning, in Go, when you use a slice for variadic expansion (s...), and you use a variadic parameter to capture said slice (paramSlice ...int), they are the same1 slice, and mutating one will mutate the other. In Python, you actually can’t do that because *args is always a tuple: def check(*args): args[1] = "hi zev" # TypeError: 'tuple' object does not support item assignment l = [1, 2, 3] check(*l) print(l) So the assignment fails, but even with **kwargs: def check(**kwargs): kwargs["1"] = "hi zev" d = {"1": None} check(**d) assert d["1"] is None, "Sanity prevails!
🌐
DZone
dzone.com › data engineering › data › python string format examples
Python String Format Examples
January 23, 2020 - By passing in an index (or positional argument), the format method will allow you to insert individual or multiple items from a list based on their index. In this example, 'world' is the first (index 0) item in our list, so it gets inserted. ... When we print our string to the console, we get: Hello world!
🌐
AllPosters.com
allposters.com
AllPosters.com | The Largest Online Store for Cool Posters, Affordable Wall Art Prints & Framed Canvas Paintings on Sale
AllPosters is your destination for posters, wall art, framed prints, and unique décor to bring your space to life. With millions of images spanning pop culture, sports, movies, music, photography, and fine art, it’s easy to find artwork that matches your style.
🌐
W3Schools
w3schools.com › python › ref_func_print.asp
Python print() Function
Python Examples Python Compiler ... Q&A Python Bootcamp Python Training ... The print() function prints the specified message to the screen, or other standard output device....
🌐
LearnPython.com
learnpython.com › blog › python-string-formatting
Python’s String format() Cheat Sheet | LearnPython.com
May 30, 2022 - What happens when we need to read the customer’s name, their order, its price, and the tip amount from variables? >>> print("customer_name ordered a order_name for price with a tip_percentage tip") customer_name ordered a order_name for price with a tip_percentage tip · That clearly won’t do. Before the introduction of Python 3, string formatting was mainly achieved through the % operator.
🌐
Note.nkmk.me
note.nkmk.me › home › python
Format Strings and Numbers in Python: format() | note.nkmk.me
May 18, 2023 - Built-in Functions - format() — Python 3.11.3 documentation · This function takes the original string (str) and number (int or float) to be formatted as its first argument, and the format specification string as its second argument.
🌐
Python Geeks
pythongeeks.org › python geeks › learn python › strings in python
Strings in Python - Python Geeks
July 30, 2021 - The below example shows that. ... The str() function can be used for conversion from another data type to string. Some examples are shown below. ... str1=str(4.5) print("The type of str1 is:",type(str1)) str2=str(7+0j) print("The type of str2 ...
🌐
Python documentation
docs.python.org › 3 › tutorial › inputoutput.html
7. Input and Output — Python 3.14.5 documentation
For reading lines from a file, you can loop over the file object. This is memory efficient, fast, and leads to simple code: >>> for line in f: ... print(line, end='') ... This is the first line of the file.
🌐
Canard Analytics
canardanalytics.com › blog › python-string-formatting
A Guide to String Formatting in Python | Canard Analytics
June 3, 2022 - The printf string formatting style ... The ‘s’ in the example below is called a conversion specifier, and tells python to apply the str() function to the variable, and turn that variable into a string for printing....
🌐
Mooc
programming-23.mooc.fi › part-4 › 5-print-statement-formatting
Print statement formatting - Python Programming MOOC 2023
The first is the + operator for strings. It allows simple concatenation of string segments: name = "Mark" age = 37 print("Hi " + name + " your age is " + str(age) + " years" )