{"id":728,"date":"2023-11-13T18:10:24","date_gmt":"2024-03-01T01:47:34","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/index.php\/2023\/11\/30\/python-f-strings-%e5%8d%b3-pep-498-%e5%ad%97%e7%ac%a6%e4%b8%b2%e6%8f%92%e5%80%bc\/"},"modified":"2025-08-03T05:18:17","modified_gmt":"2025-08-02T21:18:17","slug":"python-f-strings-%e5%8d%b3-pep-498-%e5%ad%97%e7%ac%a6%e4%b8%b2%e6%8f%92%e5%80%bc","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/python-f-strings-%e5%8d%b3-pep-498-%e5%ad%97%e7%ac%a6%e4%b8%b2%e6%8f%92%e5%80%bc\/","title":{"rendered":"Python f-strings\u5b8c\u5168\u6307\u5357\uff1a\u638c\u63e1PEP 498\u5b57\u7b26\u4e32\u63d2\u503c\u6280\u5de7"},"content":{"rendered":"<p>\u8fd9\u662f\u6587\u7ae0\u300aPython f-strings \u5373 PEP 498 &#8211; \u5b57\u7b26\u4e32\u63d2\u503c\u300b\u7684\u7b2c1\u90e8\u5206\uff08\u51711\u90e8\u5206\uff09\u3002<\/p>\n<p>Python f-strings\uff08\u683c\u5f0f\u5316\u5b57\u7b26\u4e32\uff09\u662f\u4e00\u79cd\u65b0\u7684\u5b57\u7b26\u4e32\u683c\u5f0f\u5316\u65b9\u6cd5\u3002\u8fd9\u4e2a\u529f\u80fd\u662f\u901a\u8fc7PEP-498\u5728Python 3.6\u4e2d\u5f15\u5165\u7684\uff0c\u4e5f\u88ab\u79f0\u4e3a\u5b57\u9762\u5b57\u7b26\u4e32\u63d2\u503c\u3002<\/p>\n<h2>\u6211\u4eec\u4e3a\u4ec0\u4e48\u9700\u8981f-strings\uff1f<\/h2>\n<p>Python\u63d0\u4f9b\u4e86\u591a\u79cd\u683c\u5f0f\u5316\u5b57\u7b26\u4e32\u7684\u65b9\u6cd5\u3002\u8ba9\u6211\u4eec\u5feb\u901f\u6d4f\u89c8\u4e00\u4e0b\u5b83\u4eec\u4ee5\u53ca\u5b83\u4eec\u53ef\u80fd\u9047\u5230\u7684\u95ee\u9898\u3002<\/p>\n<ul class=\"post-ul\">\n<li>% \u683c\u5f0f\u5316 &#8211; \u9002\u7528\u4e8e\u7b80\u5355\u683c\u5f0f\u5316\uff0c\u4f46\u4ec5\u652f\u6301\u5b57\u7b26\u4e32\u3001\u6574\u6570\u548c\u53cc\u7cbe\u5ea6\u6d6e\u70b9\u6570\u3002\u6211\u4eec\u4e0d\u80fd\u5c06\u5176\u7528\u4e8e\u5bf9\u8c61\u3002<\/li>\n<li>\u6a21\u677f\u5b57\u7b26\u4e32 &#8211; \u975e\u5e38\u57fa\u7840\u3002\u6a21\u677f\u5b57\u7b26\u4e32\u53ea\u9002\u7528\u4e8e\u7c7b\u4f3c\u5b57\u5178\u7684\u5173\u952e\u5b57\u53c2\u6570\u3002\u4e0d\u5141\u8bb8\u8c03\u7528\u4efb\u4f55\u51fd\u6570\uff0c\u4e14\u53c2\u6570\u5fc5\u987b\u662f\u5b57\u7b26\u4e32\u3002<\/li>\n<li>\u5b57\u7b26\u4e32format() &#8211; Python\u5b57\u7b26\u4e32format()\u51fd\u6570\u7684\u5f15\u5165\u662f\u4e3a\u4e86\u514b\u670d%\u683c\u5f0f\u5316\u548c\u6a21\u677f\u5b57\u7b26\u4e32\u7684\u95ee\u9898\u548c\u529f\u80fd\u9650\u5236\u3002\u7136\u800c\uff0c\u5b83\u8fc7\u4e8e\u5197\u957f\u3002\u8ba9\u6211\u4eec\u901a\u8fc7\u4e00\u4e2a\u7b80\u5355\u4f8b\u5b50\u770b\u770b\u5b83\u7684\u5197\u957f\u6027\u3002<br \/>\n&gt;&gt;&gt; age = 4 * 10<br \/>\n&gt;&gt;&gt; &#8216;\u6211\u7684\u5e74\u9f84\u662f{age}\u3002&#8217;.format(age=age)<br \/>\n&#8216;\u6211\u7684\u5e74\u9f84\u662f40\u3002&#8217;<\/li>\n<\/ul>\n<p>Python f-strings\u548cformat\u51fd\u6570\u51e0\u4e4e\u7c7b\u4f3c\uff0c\u4f46\u662f\u53bb\u9664\u4e86format\u51fd\u6570\u7684\u5197\u957f\u6027\u3002\u8ba9\u6211\u4eec\u770b\u770b\u5982\u4f55\u4f7f\u7528f-strings\u8f7b\u677e\u5730\u683c\u5f0f\u5316\u4e0a\u8ff0\u5b57\u7b26\u4e32\u3002<\/p>\n<pre class=\"post-pre\"><code>&gt;&gt;&gt; f'\u6211\u7684\u5e74\u9f84\u662f{age}'\r\n'\u6211\u7684\u5e74\u9f84\u662f40\u3002'\r\n<\/code><\/pre>\n<p>Python f-strings\u662f\u4e3a\u4e86\u5728\u5b57\u7b26\u4e32\u683c\u5f0f\u5316\u65f6\u63d0\u4f9b\u6700\u7b80\u5316\u7684\u8bed\u6cd5\u800c\u5f15\u5165\u7684\u3002\u8fd9\u4e9b\u8868\u8fbe\u5f0f\u5728\u8fd0\u884c\u65f6\u88ab\u6c42\u503c\u3002\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662fPython 3.6\u6216\u66f4\u9ad8\u7248\u672c\uff0c\u4f60\u5e94\u8be5\u4f7f\u7528f-strings\u6765\u6ee1\u8db3\u4f60\u6240\u6709\u7684\u5b57\u7b26\u4e32\u683c\u5f0f\u5316\u9700\u6c42\u3002<\/p>\n<h2>Python f\u5b57\u7b26\u4e32\u793a\u4f8b<\/h2>\n<p>\u8ba9\u6211\u4eec\u6765\u770b\u4e00\u4e2a\u5173\u4e8ef-strings\u7684\u7b80\u5355\u4f8b\u5b50\u3002<\/p>\n<pre class=\"post-pre\"><code>name = 'Pankaj'\r\nage = 34\r\n\r\nf_string = f'\u6211\u7684\u540d\u5b57\u662f{name}\uff0c\u6211\u7684\u5e74\u9f84\u662f{age}'\r\n\r\nprint(f_string)\r\nprint(F'\u6211\u7684\u540d\u5b57\u662f{name}\uff0c\u6211\u7684\u5e74\u9f84\u662f{age}')  # f\u548cF\u662f\u76f8\u540c\u7684\r\n\r\nname = 'David'\r\nage = 40\r\n\r\n# f_string\u5df2\u7ecf\u88ab\u8bc4\u4f30\uff0c\u73b0\u5728\u4e0d\u4f1a\u6539\u53d8\r\nprint(f_string)\r\n<\/code><\/pre>\n<p>\u8f93\u51fa\uff1a<\/p>\n<pre class=\"post-pre\"><code>\u6211\u7684\u540d\u5b57\u662fPankaj\uff0c\u6211\u7684\u5e74\u9f84\u662f34\r\n\u6211\u7684\u540d\u5b57\u662fPankaj\uff0c\u6211\u7684\u5e74\u9f84\u662f34\r\n\u6211\u7684\u540d\u5b57\u662fPankaj\uff0c\u6211\u7684\u5e74\u9f84\u662f34\r\n<\/code><\/pre>\n<p>Python\u9010\u53e5\u6267\u884c\u8bed\u53e5\uff0c\u4e00\u65e6f-string\u8868\u8fbe\u5f0f\u88ab\u8bc4\u4f30\uff0c\u5373\u4f7f\u8868\u8fbe\u5f0f\u503c\u53d1\u751f\u53d8\u5316\uff0c\u5b83\u4eec\u4e5f\u4e0d\u4f1a\u6539\u53d8\u3002\u8fd9\u5c31\u662f\u4e3a\u4ec0\u4e48\u5728\u4e0a\u8ff0\u4ee3\u7801\u7247\u6bb5\u4e2d\uff0c\u5373\u4f7f\u5728\u7a0b\u5e8f\u7684\u540e\u534a\u90e8\u5206&#8217;\u59d3\u540d&#8217;\u548c&#8217;\u5e74\u9f84&#8217;\u53d8\u91cf\u5df2\u7ecf\u6539\u53d8\uff0cf_string\u7684\u503c\u4ecd\u7136\u4fdd\u6301\u4e0d\u53d8\u3002<\/p>\n<h3>1. \u8868\u8fbe\u5f0f\u548c\u8f6c\u6362\u7684f-strings<\/h3>\n<p>\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528f-strings\u5c06\u65e5\u671f\u65f6\u95f4\u8f6c\u6362\u4e3a\u7279\u5b9a\u7684\u683c\u5f0f\u3002\u6211\u4eec\u8fd8\u53ef\u4ee5\u5728f-strings\u4e2d\u8fd0\u884c\u6570\u5b66\u8868\u8fbe\u5f0f\u3002<\/p>\n<pre class=\"post-pre\"><code>from datetime import datetime\r\n\r\nname = 'David'\r\nage = 40\r\nd = datetime.now()\r\n\r\nprint(f'\u4e94\u5e74\u540e\u7684\u5e74\u9f84\u5c06\u662f{age+5}')  # age = 40\r\nprint(f'\u5e26\u5f15\u53f7\u7684\u540d\u5b57 = {name!r}')  # name = David\r\nprint(f'\u9ed8\u8ba4\u683c\u5f0f\u5316\u7684\u65e5\u671f = {d}')\r\nprint(f'\u81ea\u5b9a\u4e49\u683c\u5f0f\u5316\u7684\u65e5\u671f = {d:%m\/%d\/%Y}')\r\n<\/code><\/pre>\n<p>\u8f93\u51fa\uff1a<\/p>\n<pre class=\"post-pre\"><code>\u4e94\u5e74\u540e\u7684\u5e74\u9f84\u5c06\u662f45\r\n\u5e26\u5f15\u53f7\u7684\u540d\u5b57 = 'David'\r\n\u9ed8\u8ba4\u683c\u5f0f\u5316\u7684\u65e5\u671f = 2018-10-10 11:47:12.818831\r\n\u81ea\u5b9a\u4e49\u683c\u5f0f\u5316\u7684\u65e5\u671f = 10\/10\/2018\r\n<\/code><\/pre>\n<h3>2. f-strings\u652f\u6301\u539f\u59cb\u5b57\u7b26\u4e32<\/h3>\n<p>\u6211\u4eec\u4e5f\u53ef\u4ee5\u4f7f\u7528f-strings\u6765\u521b\u5efa\u539f\u59cb\u5b57\u7b26\u4e32\u3002<\/p>\n<pre class=\"post-pre\"><code>print(f'\u9ed8\u8ba4\u683c\u5f0f\u5316\u7684\u65e5\u671f:\\n{d}')\r\nprint(fr'\u9ed8\u8ba4\u683c\u5f0f\u5316\u7684\u65e5\u671f:\\n {d}')\r\n<\/code><\/pre>\n<p>\u8f93\u51fa\uff1a<\/p>\n<pre class=\"post-pre\"><code>\u9ed8\u8ba4\u683c\u5f0f\u5316\u7684\u65e5\u671f:\r\n2018-10-10 11:47:12.818831\r\n\u9ed8\u8ba4\u683c\u5f0f\u5316\u7684\u65e5\u671f:\\n 2018-10-10 11:47:12.818831\r\n<\/code><\/pre>\n<h3>3. \u4f7f\u7528\u5bf9\u8c61\u548c\u5c5e\u6027\u7684f-strings<\/h3>\n<p>\u6211\u4eec\u4e5f\u53ef\u4ee5\u5728f-strings\u4e2d\u8bbf\u95ee\u5bf9\u8c61\u5c5e\u6027\u3002<\/p>\n<pre class=\"post-pre\"><code>class Employee:\r\n    id = 0\r\n    name = ''\r\n\r\n    def __init__(self, i, n):\r\n        self.id = i\r\n        self.name = n\r\n\r\n    def __str__(self):\r\n        return f'E[id={self.id}, name={self.name}]'\r\n\r\n\r\nemp = Employee(10, 'Pankaj')\r\nprint(emp)\r\n\r\nprint(f'\u5458\u5de5: {emp}\\n\u59d3\u540d\u662f{emp.name}\uff0cID\u662f{emp.id}')\r\n<\/code><\/pre>\n<p>\u8f93\u51fa\uff1a<\/p>\n<pre class=\"post-pre\"><code>E[id=10, name=Pankaj]\r\n\u5458\u5de5: E[id=10, name=Pankaj]\r\n\u59d3\u540d\u662fPankaj\uff0cID\u662f10\r\n<\/code><\/pre>\n<h3>4. \u4f7f\u7528f\u5b57\u7b26\u4e32\u8c03\u7528\u51fd\u6570<\/h3>\n<p>\u6211\u4eec\u53ef\u4ee5\u5728f-strings\u683c\u5f0f\u5316\u4e2d\u8c03\u7528\u51fd\u6570\u3002<\/p>\n<pre class=\"post-pre\"><code>def add(x, y):\r\n    return x + y\r\n\r\n\r\nprint(f'\u6c42\u548c(10,20) = {add(10, 20)}')\r\n<\/code><\/pre>\n<p>\u8f93\u51fa\uff1a<\/p>\n<pre class=\"post-pre\"><code>\u6c42\u548c(10,20) = 30\r\n<\/code><\/pre>\n<h3>5. \u5e26\u7a7a\u683c\u7684f\u5b57\u7b26\u4e32<\/h3>\n<p>\u5982\u679c\u8868\u8fbe\u5f0f\u4e2d\u5305\u542b\u524d\u5bfc\u6216\u5c3e\u968f\u7a7a\u683c\uff0c\u5219\u4f1a\u88ab\u5ffd\u7565\u3002\u5982\u679c\u6587\u5b57\u5b57\u7b26\u4e32\u90e8\u5206\u5305\u542b\u7a7a\u683c\uff0c\u5219\u4f1a\u4fdd\u7559\u5b83\u4eec\u3002<\/p>\n<pre class=\"post-pre\"><code>&gt;&gt;&gt; age = 4 * 20\r\n&gt;&gt;&gt; f'   \u5e74\u9f84 = {  age   }  '\r\n'   \u5e74\u9f84 = 80  '\r\n<\/code><\/pre>\n<h3>6. \u4f7f\u7528f-\u5b57\u7b26\u4e32\u7684Lambda\u8868\u8fbe\u5f0f<\/h3>\n<p>\u6211\u4eec\u4e5f\u53ef\u4ee5\u5728f-string\u8868\u8fbe\u5f0f\u4e2d\u4f7f\u7528lambda\u8868\u8fbe\u5f0f\u3002<\/p>\n<pre class=\"post-pre\"><code>x = -20.45\r\nprint(f'Lambda\u793a\u4f8b: {(lambda x: abs(x)) (x)}')\r\n\r\nprint(f'Lambda\u5e73\u65b9\u793a\u4f8b: {(lambda x: pow(x, 2)) (5)}')\r\n<\/code><\/pre>\n<p>\u7ed3\u679c\uff1a<\/p>\n<pre class=\"post-pre\"><code>Lambda\u793a\u4f8b: 20.45\r\nLambda\u5e73\u65b9\u793a\u4f8b: 25\r\n<\/code><\/pre>\n<h3>7. f-\u5b57\u7b26\u4e32\u7684\u5176\u4ed6\u4f8b\u5b50<\/h3>\n<p>\u8ba9\u6211\u4eec\u770b\u4e00\u4e9bPython f-strings\u7684\u5176\u4ed6\u4f8b\u5b50\u3002<\/p>\n<pre class=\"post-pre\"><code>print(f'{\"\u5e26\u5f15\u53f7\u7684\u5b57\u7b26\u4e32\"}')\r\nprint(f'{{ {4*10} }}')\r\nprint(f'{{{4*10}}}')\r\n<\/code><\/pre>\n<p>\u8f93\u51fa\uff1a<\/p>\n<pre class=\"post-pre\"><code>\u5e26\u5f15\u53f7\u7684\u5b57\u7b26\u4e32\r\n{ 40 }\r\n{40}\r\n<\/code><\/pre>\n<p>\u5173\u4e8ePython\u683c\u5f0f\u5316\u5b57\u7b26\u4e32\uff0c\u4e5f\u5c31\u662ff-strings\uff0c\u5c31\u662f\u8fd9\u4e9b\u4e86\u3002<\/p>\n<p>\u4f60\u53ef\u4ee5\u4ece\u6211\u4eec\u7684GitHub\u4ee3\u7801\u5e93\u4e2d\u67e5\u770b\u5b8c\u6574\u7684Python\u811a\u672c\u548c\u66f4\u591a\u7684Python\u793a\u4f8b\u3002<\/p>\n<p>\u53c2\u8003\u6587\u732e\uff1aPEP-498\uff0c\u5b98\u65b9\u6587\u6863\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u662f\u6587\u7ae0\u300aPython f-strings \u5373 PEP 498 &#8211; \u5b57\u7b26\u4e32\u63d2\u503c\u300b\u7684\u7b2c1\u90e8\u5206\uff08\u51711\u90e8 [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[2000,2001,32,280,2002],"class_list":{"0":"post-728","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-uncategorized","7":"tag-f-strings","8":"tag-pep-498","9":"tag-python","11":"tag-2002"},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python f-strings\u5b8c\u5168\u6307\u5357\uff1a\u638c\u63e1PEP 498\u5b57\u7b26\u4e32\u63d2\u503c\u6280\u5de7 - Blog - Silicon Cloud<\/title>\n<meta name=\"description\" content=\"\u6df1\u5165\u4e86\u89e3Python f-strings\uff08PEP 498\uff09\u5b57\u7b26\u4e32\u63d2\u503c\u6280\u672f\u3002\u672c\u6559\u7a0b\u8be6\u7ec6\u8bb2\u89e3f-strings\u7684\u8bed\u6cd5\u3001\u7528\u6cd5\u548c\u9ad8\u7ea7\u6280\u5de7\uff0c\u5e2e\u52a9\u4f60\u638c\u63e1\u8fd9\u4e00\u5f3a\u5927\u7684\u5b57\u7b26\u4e32\u683c\u5f0f\u5316\u65b9\u6cd5\u3002\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/zh\/blog\/python-f-strings-\u5373-pep-498-\u5b57\u7b26\u4e32\u63d2\u503c\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python f-strings\u5b8c\u5168\u6307\u5357\uff1a\u638c\u63e1PEP 498\u5b57\u7b26\u4e32\u63d2\u503c\u6280\u5de7\" \/>\n<meta property=\"og:description\" content=\"\u6df1\u5165\u4e86\u89e3Python f-strings\uff08PEP 498\uff09\u5b57\u7b26\u4e32\u63d2\u503c\u6280\u672f\u3002\u672c\u6559\u7a0b\u8be6\u7ec6\u8bb2\u89e3f-strings\u7684\u8bed\u6cd5\u3001\u7528\u6cd5\u548c\u9ad8\u7ea7\u6280\u5de7\uff0c\u5e2e\u52a9\u4f60\u638c\u63e1\u8fd9\u4e00\u5f3a\u5927\u7684\u5b57\u7b26\u4e32\u683c\u5f0f\u5316\u65b9\u6cd5\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/python-f-strings-\u5373-pep-498-\u5b57\u7b26\u4e32\u63d2\u503c\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2024-03-01T01:47:34+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-08-02T21:18:17+00:00\" \/>\n<meta name=\"author\" content=\"\u79d1, \u9896\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u79d1, \u9896\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/python-f-strings-%e5%8d%b3-pep-498-%e5%ad%97%e7%ac%a6%e4%b8%b2%e6%8f%92%e5%80%bc\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/python-f-strings-%e5%8d%b3-pep-498-%e5%ad%97%e7%ac%a6%e4%b8%b2%e6%8f%92%e5%80%bc\/\",\"name\":\"Python f-strings\u5b8c\u5168\u6307\u5357\uff1a\u638c\u63e1PEP 498\u5b57\u7b26\u4e32\u63d2\u503c\u6280\u5de7 - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2024-03-01T01:47:34+00:00\",\"dateModified\":\"2025-08-02T21:18:17+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/8ca01ba7f7362ad4edb7da206a12f29e\"},\"description\":\"\u6df1\u5165\u4e86\u89e3Python f-strings\uff08PEP 498\uff09\u5b57\u7b26\u4e32\u63d2\u503c\u6280\u672f\u3002\u672c\u6559\u7a0b\u8be6\u7ec6\u8bb2\u89e3f-strings\u7684\u8bed\u6cd5\u3001\u7528\u6cd5\u548c\u9ad8\u7ea7\u6280\u5de7\uff0c\u5e2e\u52a9\u4f60\u638c\u63e1\u8fd9\u4e00\u5f3a\u5927\u7684\u5b57\u7b26\u4e32\u683c\u5f0f\u5316\u65b9\u6cd5\u3002\",\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/python-f-strings-%e5%8d%b3-pep-498-%e5%ad%97%e7%ac%a6%e4%b8%b2%e6%8f%92%e5%80%bc\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/python-f-strings-%e5%8d%b3-pep-498-%e5%ad%97%e7%ac%a6%e4%b8%b2%e6%8f%92%e5%80%bc\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/python-f-strings-%e5%8d%b3-pep-498-%e5%ad%97%e7%ac%a6%e4%b8%b2%e6%8f%92%e5%80%bc\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python f-strings\u5b8c\u5168\u6307\u5357\uff1a\u638c\u63e1PEP 498\u5b57\u7b26\u4e32\u63d2\u503c\u6280\u5de7\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/8ca01ba7f7362ad4edb7da206a12f29e\",\"name\":\"\u79d1, \u9896\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/8a6fb3cc7ba2f69d2189ba532aec4633ea7ed75ac0af162ec367cb3abc0fb2af?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/8a6fb3cc7ba2f69d2189ba532aec4633ea7ed75ac0af162ec367cb3abc0fb2af?s=96&d=mm&r=g\",\"caption\":\"\u79d1, \u9896\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/keying\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/python-f-strings-%e5%8d%b3-pep-498-%e5%ad%97%e7%ac%a6%e4%b8%b2%e6%8f%92%e5%80%bc\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Python f-strings\u5b8c\u5168\u6307\u5357\uff1a\u638c\u63e1PEP 498\u5b57\u7b26\u4e32\u63d2\u503c\u6280\u5de7 - Blog - Silicon Cloud","description":"\u6df1\u5165\u4e86\u89e3Python f-strings\uff08PEP 498\uff09\u5b57\u7b26\u4e32\u63d2\u503c\u6280\u672f\u3002\u672c\u6559\u7a0b\u8be6\u7ec6\u8bb2\u89e3f-strings\u7684\u8bed\u6cd5\u3001\u7528\u6cd5\u548c\u9ad8\u7ea7\u6280\u5de7\uff0c\u5e2e\u52a9\u4f60\u638c\u63e1\u8fd9\u4e00\u5f3a\u5927\u7684\u5b57\u7b26\u4e32\u683c\u5f0f\u5316\u65b9\u6cd5\u3002","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/zh\/blog\/python-f-strings-\u5373-pep-498-\u5b57\u7b26\u4e32\u63d2\u503c\/","og_locale":"zh_CN","og_type":"article","og_title":"Python f-strings\u5b8c\u5168\u6307\u5357\uff1a\u638c\u63e1PEP 498\u5b57\u7b26\u4e32\u63d2\u503c\u6280\u5de7","og_description":"\u6df1\u5165\u4e86\u89e3Python f-strings\uff08PEP 498\uff09\u5b57\u7b26\u4e32\u63d2\u503c\u6280\u672f\u3002\u672c\u6559\u7a0b\u8be6\u7ec6\u8bb2\u89e3f-strings\u7684\u8bed\u6cd5\u3001\u7528\u6cd5\u548c\u9ad8\u7ea7\u6280\u5de7\uff0c\u5e2e\u52a9\u4f60\u638c\u63e1\u8fd9\u4e00\u5f3a\u5927\u7684\u5b57\u7b26\u4e32\u683c\u5f0f\u5316\u65b9\u6cd5\u3002","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/python-f-strings-\u5373-pep-498-\u5b57\u7b26\u4e32\u63d2\u503c\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2024-03-01T01:47:34+00:00","article_modified_time":"2025-08-02T21:18:17+00:00","author":"\u79d1, \u9896","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u79d1, \u9896","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/python-f-strings-%e5%8d%b3-pep-498-%e5%ad%97%e7%ac%a6%e4%b8%b2%e6%8f%92%e5%80%bc\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/python-f-strings-%e5%8d%b3-pep-498-%e5%ad%97%e7%ac%a6%e4%b8%b2%e6%8f%92%e5%80%bc\/","name":"Python f-strings\u5b8c\u5168\u6307\u5357\uff1a\u638c\u63e1PEP 498\u5b57\u7b26\u4e32\u63d2\u503c\u6280\u5de7 - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2024-03-01T01:47:34+00:00","dateModified":"2025-08-02T21:18:17+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/8ca01ba7f7362ad4edb7da206a12f29e"},"description":"\u6df1\u5165\u4e86\u89e3Python f-strings\uff08PEP 498\uff09\u5b57\u7b26\u4e32\u63d2\u503c\u6280\u672f\u3002\u672c\u6559\u7a0b\u8be6\u7ec6\u8bb2\u89e3f-strings\u7684\u8bed\u6cd5\u3001\u7528\u6cd5\u548c\u9ad8\u7ea7\u6280\u5de7\uff0c\u5e2e\u52a9\u4f60\u638c\u63e1\u8fd9\u4e00\u5f3a\u5927\u7684\u5b57\u7b26\u4e32\u683c\u5f0f\u5316\u65b9\u6cd5\u3002","breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/python-f-strings-%e5%8d%b3-pep-498-%e5%ad%97%e7%ac%a6%e4%b8%b2%e6%8f%92%e5%80%bc\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/python-f-strings-%e5%8d%b3-pep-498-%e5%ad%97%e7%ac%a6%e4%b8%b2%e6%8f%92%e5%80%bc\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/python-f-strings-%e5%8d%b3-pep-498-%e5%ad%97%e7%ac%a6%e4%b8%b2%e6%8f%92%e5%80%bc\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"Python f-strings\u5b8c\u5168\u6307\u5357\uff1a\u638c\u63e1PEP 498\u5b57\u7b26\u4e32\u63d2\u503c\u6280\u5de7"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/8ca01ba7f7362ad4edb7da206a12f29e","name":"\u79d1, \u9896","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/8a6fb3cc7ba2f69d2189ba532aec4633ea7ed75ac0af162ec367cb3abc0fb2af?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8a6fb3cc7ba2f69d2189ba532aec4633ea7ed75ac0af162ec367cb3abc0fb2af?s=96&d=mm&r=g","caption":"\u79d1, \u9896"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/keying\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/python-f-strings-%e5%8d%b3-pep-498-%e5%ad%97%e7%ac%a6%e4%b8%b2%e6%8f%92%e5%80%bc\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/728","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=728"}],"version-history":[{"count":4,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/728\/revisions"}],"predecessor-version":[{"id":110576,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/728\/revisions\/110576"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=728"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=728"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=728"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}