name = "John"
age = 25
print("{:<10} is {} years old".format(name, age))
name = "John"
age = 25
print("{:>10} is {} years old".format(name, age))
name = "John"
age = 25
print("{:^10} is {} years old".format(name, age))
name = "John"
age = 25
print("{:20} is {} years old".format(name, age))
name = "John"
age = 25
print("{:_<10} is {} years old".format(name, age))
pi = 3.14159
print("{:.2f}".format(pi))
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:Python中print的进阶技巧有哪些