print variable into a string : Output Format « Development « Python
- Python
- Development
- Output Format
print variable into a string

x = 42
y = 3.14
z = "george"
print 'result = %d' % x # prints: result = 42
print 'answers are: %d %f' % (x,y) # prints: answers are: 42 3.14
print 'hello %s' % z # prints: hello george
Related examples in the same category