慕村225694
这个format方法是在Python2.6中引入的。它更有能力,使用起来也不难:>>> "Hello {}, my name is {}".format('john', 'mike')'Hello john, my name is mike'.>>> "{1}, {0}".format('world', 'Hello')'Hello, world'>>> "{greeting}, {}".format('world', greeting='Hello')'Hello, world'>>> '%s' % name"{'s1': 'hello', 's2': 'sibal'}">>> '%s' %name['s1']'hello'