# %s 字符串占位符
# %d 占位整数
# %f 占位小数
# f f-string python高版本才有的
name="Sakura"
address="China"
age=18
s = "我叫%s,我住在%s,我今年%d岁"% (name,address,age)
s1 = "我叫%s"%name;
s2 = "我叫{},我住在{},我今年{}岁".format(name,address,age)
s3 = f"我叫{name},我住在{address},我今年{age}岁"
print(s3)
Python-字符串的格式化
发布于 2022-12-15 363 次阅读
Comments NOTHING