Using multiple arguments for string formatting in Python (e.g., '%s … %s')

后端 未结 8 2130
谎友^
谎友^ 2020-12-04 08:16

I have a string that looks like \'%s in %s\' and I want to know how to seperate the arguments so that they are two different %s. My mind coming from Java came u

8条回答
  •  死守一世寂寞
    2020-12-04 08:57

    You could also use it clean and simple (but wrong! because you should use format like Mark Byers said) by doing:

    print 'This is my %s formatted with %d arguments' % ('string', 2)
    

提交回复
热议问题