GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Processing
  • p5.js
  • Processing.py
  • Processing for Android
  • Processing for Pi
  • Processing Foundation

This view

  • Original page
  • New address

GeezerVison is showing py.processing.org — String Formatting \ Language (API)

Python Mode for Processing is no longer maintained. This site is kept as an archive. Read more
  • Processing
  • p5.js
  • Processing.py
  • Processing for Android
  • Processing for Pi
  • Processing Foundation
Cover
Reference
Tutorials
Examples
Bugs
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 Substitute variables in a string using the string format operator % as shown above. Symbols that can be used with % include: %i for integers, %f for floats and %s for strings.
Syntax
	"%s" % "string"
	"%i" % 10 
	"%f" % 10.5
Parameters
%sString: any string
%iint: any int
%ffloat: any float
Related string
.find()
.strip()
.join()
.replace()

Updated on Sat Oct 24 11:26:09 2026.

If you see any errors or have comments, please let us know.

Creative Commons License

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.