Python中的字符串格式化

Python中的字符串格式化,第1张

# 字符串格式化
name = "董付国"
score = 90

result1 = "在考试中%s的成绩为%s" % (name, score)
print(result1)
result2 = "在考试中{1}的成绩为{0}".format(score, name)
print(result2)
result3 = f"在考试中{name}的成绩为{score}"
print(result3)

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/569418.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-09
下一篇 2022-04-09

发表评论

登录后才能评论

评论列表(0条)

保存