string template python
print("Hello {planet}".format(planet='World'))
#or
i = "Hello"
print("{word} World".format(word= i ))
3.67
6
from string import Template
poem = Template('$x are red and $y are blue')
print(poem.substitute(x='roses', y='violets'))
#>>>roses are red and violets are blue
Thank you!
6
0
4
1
>>> 'Hello, {}'.format(name)
name='Bob'
'Hello, Bob'
Thank you!
1
0
Are there any code examples left?
New code examples in category Python