Integer and String Output : integer format « Data Type « Python Tutorial






print "%+d" % 4
print "%+d" % -4
print "we are at %d%%" % 100
print 'Your host is: %s' % 'earth'
print 'Host: %s\tPort: %d' % ('mars', 80)
num = 123
print 'dec: %d/oct: %#o/hex: %#X' % (num, num, num)
print "MM/DD/YY = %02d/%02d/%d" % (2, 15, 67)
w, p = 'Web', 'page'
print 'http://xxx.yyy.zzz/%s/%s.html' % (w, p)








2.9.integer format
2.9.1.Integer and String Output