Name

String Formatting

Examples
age = 7
animal = 'turtle'
weight = 317.5

# Format string to include animal, age, and weight to one digit after the decimal point.
s = ("This %s is %i years old, and weighs %.1f pounds." % (animal, age, weight))
print(s)
Description
Syntax
Parameters
%s
%i
%f
Related string
.find()
.strip()
.join()
.replace()
Updated on Wed Jan 18 17:32:21 2017.
Creative Commons License