温馨提示×

Python中format()函数的嵌套使用示例

小樊
85
2024-08-26 10:16:17
栏目: 编程语言
Python开发者专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

name = "Alice"
age = 30
city = "Paris"

# 使用format()函数嵌套传入变量
message = "Hello, my name is {}. I am {} years old and I live in {}.".format(name, age, city)

print(message)

输出结果:

Hello, my name is Alice. I am 30 years old and I live in Paris.

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

0