Title: String Formatting
Slug: string_formatting
Summary: String Formatting
Date: 2016-05-01 12:00
Category: Python
Tags: Basics
Authors: Chris Albon
In [1]:
import sys
In [2]:
'This is %d %s bird!' % (1, 'dead')
Out[2]:
In [3]:
'%(number)d more %(food)s' % {'number' : 1, 'food' : 'burger'}
Out[3]:
In [4]:
'My {1[kind]} runs {0.platform}'.format(sys, {'kind': 'laptop'})
Out[4]: