Python中使用f格式化字符串的用法

Python中使用f格式化字符串的用法,第1张

官方的解释:

PEP 498 – Literal String Interpolation | peps.python.org

F-strings provide a way to embed expressions inside string literals, using a minimal syntax. It should be noted that an f-string is really an expression evaluated at run time, not a constant value. In Python source code, an f-string is a literal string, prefixed with ‘f’, which contains expressions inside braces.

概要翻译一下就是:python的print字符串前面加f表示格式化字符串,加f后可以在字符串里面使用用花括号括起来的变量和表达式。

大括号=花括号=brace

括号_百度百科

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

原文地址: https://outofmemory.cn/langs/789035.html

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

发表评论

登录后才能评论

评论列表(0条)

保存