1 >>> element = 'silver' 2 >>> number = 47 3 >>> 'Element {number} is {element}'.format(**locals()) 4 'Element 47 is silver'
这里通过 映射操作符'**'将当前还在操作范围内的element,number传递给函数locals()
1 >>> element = 'silver' 2 >>> number = 47 3 >>> 'Element {number} is {element}'.format(**locals()) 4 'Element 47 is silver'
这里通过 映射操作符'**'将当前还在操作范围内的element,number传递给函数locals()