🌐
W3Schools
w3schools.com › python › ref_string_format.asp
Python String format() Method
Python Functions Python Arguments Python *args / **kwargs Python Scope Python Decorators Python Lambda Python Recursion Python Generators Code Challenge Python Range ... Magic Methods __str__ __repr__ __eq__ __add__ __len__ __lt__ __contains__ __call__ Code Challenge Python Inheritance
🌐
Python
docs.python.org › 3 › library › string.html
string — Common string operations
See the Format examples section for some examples. “Format specifications” are used within replacement fields contained within a format string to define how individual values are presented (see Format string syntax, f-strings, and t-strings). They can also be passed directly to the built-in format() function...
Discussions

is there any difference between using string.format() or an fstring?
Don't forget that f-strings haven't been around forever. It may be partly old habits, it may be not keeping up to date with features, they may still be wanting to target a minimum python version that didn't support f-strings. I'd tend to prefer to use f-strings, but I wouldn't crucify someone for using perfectly valid language constructs. More on reddit.com
🌐 r/Python
145
317
October 9, 2022
[deleted by user]
       print('there is now' + x + starting_money)

Is line 16.

"Must be str, not int" means that you are trying to use an int as a str, and python doesn't allow it.

In line 16 you are trying to perform string concatenation with an integer, which is not allowed in python.

In python3 you can use the format function to do this.

More on reddit.com
🌐 r/learnprogramming
5
1
October 22, 2017
[Help] 'str' object has no attribute 'format'

Go to file->settings->project and check the interpreter you are using. Make sure it is actually 2.7.1

You can check what version your script is using by

import platform
print platform.python_version()

Output

C:\Anaconda\python.exe D:/Dropbox/test.py
2.7.11

Process finished with exit code 0
More on reddit.com
🌐 r/learnpython
11
3
December 22, 2015
What does __str__ method do?
Yeah, it's just so you can print it. If you try to print a variable that is not a string it won't know what to do, so when you make a __str__ method it's like saying "If I tell you to print this variable, this is how I want you to do that" More on reddit.com
🌐 r/learnpython
13
4
November 14, 2020
🌐
Programiz
programiz.com › python-programming › methods › string › format
Python String format()
Note: Argument list starts from 0 in Python. The string "Hello {0}, your balance is {1:9.3f}" is the template string. This contains the format codes for formatting. The curly braces are just placeholders for the arguments to be placed. In the above example, {0} is placeholder for "Adam" and ...
🌐
MakeUseOf
makeuseof.com › home › programming › how does the python string format() method work? 10 examples
How Does the Python String format() Method Work? 10 Examples
September 12, 2021 - The Python str.format() function lets you insert your results anywhere in a string. It works by allocating space for your results within the string using curly braces. It then writes your output to that position using the format() method. The strings outside the brace are what you call literal texts. The str.format() function accepts a value and an optional string format specifier. ... Now let's take a look at more practical examples of how to use this Python string method.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-str-function
Python str() function - GeeksforGeeks
July 15, 2025 - Explanation: Here, integer 123 is passed to str() function, which returns the string '123'. ... object (optional): The value to be converted. Can be any Python object (e.g., int, float, list, dict, bytes). encoding (optional): Used only when ...
🌐
IONOS
ionos.com › digital guide › websites › web development › python string format
How to use Python string format - IONOS
September 4, 2023 - We have to convert the number to a string using the str() function first: message = "The total price is" + str(price) + "USD".Python · This can get confusing, so it’s better to define the entire text including the place­hold­er and fill ...
🌐
Real Python
realpython.com › python-string-formatting
Python String Formatting: Available Tools and Their Features – Real Python
December 1, 2024 - However, note that dates have their own formatting, which you can learn about in the Formatting Dates section of the tutorial about Python’s string formatting mini-language. You can also take advantage of the .format() method when your data is stored in dictionaries. For example, here’s how you can update the build_student_report() function using the .format() method:
🌐
DigitalOcean
digitalocean.com › community › tutorials › how-to-use-string-formatters-in-python-3
How To Use String Formatters in Python 3 | DigitalOcean
This tutorial will guide you through some of the common uses of string formatters in Python, which can help make your code and program more readable and user…
Find elsewhere
🌐
Edureka
edureka.co › blog › format-function-in-python
Format Function in Python | Python fomrat() Function Examples | Edureka
November 27, 2024 - Palindrome in Python: How to Check a Number or String is Palindrome? ... Format Function in Python (str.format()) is technique of the string category permits you to try and do variable substitutions and data formatting. It enables you to concatenate parts of a string at desired intervals through point data format.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-string-format-method
Python String format() Method - GeeksforGeeks
July 29, 2026 - format() method is used to insert ... without modifying the original string. Example: In this example, values are inserted into a string using placeholders....
🌐
Programiz
programiz.com › python-programming › methods › built-in › str
Python str() (With Examples)
# convert a utf-8 byte object to ascii with errors ignored print(str(b, encoding='ascii', errors='ignore')) # convert a utf-8 byte object to ascii with strict error print(str(b, encoding='ascii', errors='strict')) ... pythn UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position ...
🌐
PyFormat
pyformat.info
PyFormat: Using % and .format() for great good!
With new style formatting it is possible (and in Python 2.6 even mandatory) to give placeholders an explicit positional index. This allows for re-arranging the order of display without changing the arguments. This operation is not available with old-style formatting. ... The new-style simple formatter calls by default the __format__() method of an object for its representation. If you just want to render the output of str(...) or repr(...) you can use the !s or !r conversion flags.
🌐
Vultr Docs
docs.vultr.com › python › standard library › str › format()
Python str format() - String Formatting
December 11, 2024 - Define a base string with placeholders using curly braces {}. Pass values through the format() method to replace placeholders. ... This example injects the name "Alice" into the placeholder in base_string.
🌐
Python documentation
docs.python.org › 3 › tutorial › inputoutput.html
7. Input and Output — Python 3.14.8 documentation
Often you’ll want more control ... format output. To use formatted string literals, begin a string with f or F before the opening quotation mark or triple quotation mark....
🌐
Note.nkmk.me
note.nkmk.me › home › python
Format Strings and Numbers in Python: format() | note.nkmk.me
May 18, 2023 - Built-in Types - str.format() — Python 3.11.3 documentation · In the string that calls the format() method, the {} is known as the replacement field, which is substituted with the format() method's argument. The format specification can be written after : in {}. Here is the equivalent code using the format() method, corresponding to the above example with the built-in format() function.
🌐
Tutorialspoint
tutorialspoint.com › python › python-str-function.htm
Python str() Function
Following is the syntax of Python ... object. In the following example, we are using the str() function to convert the integer "42" into a string −...
🌐
GeeksforGeeks
geeksforgeeks.org › python › string-formatting-in-python
String Formatting in Python - GeeksforGeeks
The first String is formatted with '%' and the second String is formatted with .format(). ... PEP 498 introduced a new string formatting mechanism known as Literal String Interpolation or more commonly as F-strings (because of the leading f ...
Published: March 18, 2026
🌐
W3Schools
w3schools.com › python › ref_func_str.asp
Python str() Function
Python Functions Python Arguments Python *args / **kwargs Python Scope Python Decorators Python Lambda Python Recursion Python Generators Code Challenge Python Range ... Magic Methods __str__ __repr__ __eq__ __add__ __len__ __lt__ __contains__ __call__ Code Challenge Python Inheritance
🌐
Python
docs.python.org › 3.4 › library › string.html
6.1. string — Common string operations — Python 3.4.10 documentation
format() is the primary API method. It takes a format string and an arbitrary set of positional and keyword arguments. format() is just a wrapper that calls vformat(). ... This function does the actual work of formatting.
🌐
iO Flood
ioflood.com › blog › python-string-format
Python String format() Function Guide (With Examples)
December 5, 2023 - In the above example, we’ve used the format() function to insert a variable (name) into a string (greeting). This is a basic method of string formatting in Python, but it’s just the tip of the iceberg.