2 ms·
'%d %d' % (1, 2) I would have done this as '%s %s' % (1, 2) Because we're turning everything into a string at the end of the day anyway! Yeah. Having fi
by civilian 12y ago
'%d %d' % (1, 2)
I would have done this as
'%s %s' % (1, 2)
Because we're turning everything into a string at the end of the day anyway!
Yeah. Having finished the article, .format() just isn't really needed. If I'm at the point where I'm doing templating with key:values, I'll be using jinja.
- jkbr 12y ago%d converts the value to int first which might be useful: >>> '%d' % 3.14 '3' >>> '%d' % 'foo' TypeError: %d format: a number is required, not str