1# Newer f-string format
2name = "Foo"
3age = 12
4print(f"Hello, My name is {name} and I'm {age} years old.")
5# output :
6# Hello, my name is Foo and I'm 12 years old.
1string_a = "Hello"
2string_b = "Cena"
3
4# Index based:
5print("{0}, John {1}"
6 .format(string_a, string_b))
7# Object based:
8print("{greeting}, John {last_name}"
9 .format(greeting=string_a, last_name=string_b))
10
1from datetime import datetime
2
3'{:%Y-%m-%d %H:%M}'.format(datetime(2001, 2, 3, 4, 5))