Python Forum
string formatting - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: string formatting (/thread-19435.html)



string formatting - Uchikago - Jun-28-2019

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!


RE: string formatting - buran - Jun-28-2019

>> print('some {spam}'.format(**foo)) some a >>> print(f'some {foo["eggs"]}') some b



This forum uses Lukasz Tkacz MyBB addons.
Forum use Krzysztof "Supryk" Supryczynski addons.