Output formatting in Python: replacing several %s with the same variable

Use a dictionary instead.

var="%(foo)s %(foo)s %(foo)s" % { 'foo': 'look_at_me_three_times' }

Or format with explicit numbering.

var="{0} {0} {0}".format('look_at_meeee')

Well, or format with named parameters.

var="{foo} {foo} {foo}".format(foo = 'python you so crazy')

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)