官方的解释:
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
括号_百度百科
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)