print("My name is {}".format("John"))
print("I am {} years old".format(20))
My name is John
I am 20 years old
print("Hello, {} {}. Nice to meet you!".format("Mr.", "Smith"))
Hello, Mr. Smith. Nice to meet you!
print("Hello, {first} {last}. Nice to meet you!".format(first="John", last="Doe"))
Hello, John Doe. Nice to meet you!
person = {"first": "John", "last": "Doe"}
print("Hello, {first} {last}. Nice to meet you!".format(**person))
Hello, John Doe. Nice to meet you!
print("The value of X is {:0.2f}".format(3.14159))
The value of X is 3.14
print("{:<10}{}".format("Left", "Right"))
print("{:>10}{}".format("Left", "Right"))
Left Right
LeftRight
print("{{ {} }}".format("Hello"))
{ Hello }
标签: css