[Level 2] Replace doc by variable name in Python.

#!/bin/env python
doc = '''
a: %(a)s
b: %(b)s
c: %(c)s
d: %(d)s
'''

dict = {
'a': 'a1',
'b': 'b1',
'c': 'c1',
'd': 'd1',
}

print doc % dict
$ /tmp/t.py 

a: a1
b: b1
c: c1
d: d1

$
Wish this helps. regards, Stanley Huang

Comments

Popular posts from this blog

[Level 2] Shell Interactive With Zenity Episode 5 -- list

[Level 2] iif in Python