Python Forum

Full Version: string formatting
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, i want to ask that when using string formatting:
>>> b={1:'a','1':'c'}
>>> print('%(1)s abcd' % b)
c abcd
How can we refer to the keys 1 (has value 'a') not the key '1' (has 'c' value).
Thank you very much!
>> print('some {spam}'.format(**foo))
some a
>>> print(f'some {foo["eggs"]}')
some b