{"id":1109911,"date":"2025-01-08T17:14:43","date_gmt":"2025-01-08T09:14:43","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1109911.html"},"modified":"2025-01-08T17:14:46","modified_gmt":"2025-01-08T09:14:46","slug":"python%e5%a6%82%e4%bd%95%e5%9c%a8%e4%b8%80%e4%b8%aa%e7%a8%8b%e5%ba%8f%e9%87%8c%e5%8a%a0%e5%87%8f","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1109911.html","title":{"rendered":"python\u5982\u4f55\u5728\u4e00\u4e2a\u7a0b\u5e8f\u91cc\u52a0\u51cf"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25072940\/a31d4135-4d37-48ce-9d63-ccb2b92d1a1c.webp\" alt=\"python\u5982\u4f55\u5728\u4e00\u4e2a\u7a0b\u5e8f\u91cc\u52a0\u51cf\" \/><\/p>\n<p><p> <strong>Python\u7a0b\u5e8f\u4e2d\u5982\u4f55\u8fdb\u884c\u52a0\u51cf\u64cd\u4f5c<\/strong><\/p>\n<\/p>\n<p><p>\u5728Python\u7a0b\u5e8f\u4e2d\u8fdb\u884c\u52a0\u51cf\u64cd\u4f5c\u975e\u5e38\u7b80\u5355\uff0c\u4e3b\u8981\u901a\u8fc7\u57fa\u672c\u7684\u7b97\u672f\u8fd0\u7b97\u7b26\u6765\u5b9e\u73b0\u3002<strong>\u4f7f\u7528\u52a0\u53f7\uff08+\uff09\u8fdb\u884c\u52a0\u6cd5\u3001\u4f7f\u7528\u51cf\u53f7\uff08-\uff09\u8fdb\u884c\u51cf\u6cd5\u3001\u786e\u4fdd\u6570\u636e\u7c7b\u578b\u3001\u901a\u8fc7\u53d8\u91cf\u5b58\u50a8\u7ed3\u679c<\/strong>\u3002\u4e0b\u9762\u6211\u4eec\u5c06\u8be6\u7ec6\u8bb2\u89e3\u8fd9\u4e9b\u64cd\u4f5c\uff0c\u5e76\u63d0\u4f9b\u4e00\u4e9b\u5b9e\u7528\u7684\u4f8b\u5b50\u6765\u5e2e\u52a9\u4f60\u66f4\u597d\u5730\u7406\u89e3\u548c\u5e94\u7528\u8fd9\u4e9b\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4f7f\u7528\u52a0\u53f7\uff08+\uff09\u8fdb\u884c\u52a0\u6cd5<\/h3>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0c\u52a0\u6cd5\u64cd\u4f5c\u53ef\u4ee5\u4f7f\u7528\u52a0\u53f7\uff08+\uff09\u6765\u5b9e\u73b0\u3002\u4f60\u53ef\u4ee5\u5bf9\u6574\u6570\u3001\u6d6e\u70b9\u6570\u3001\u751a\u81f3\u5b57\u7b26\u4e32\u8fdb\u884c\u52a0\u6cd5\u64cd\u4f5c\u3002\u52a0\u6cd5\u64cd\u4f5c\u7684\u7ed3\u679c\u4f9d\u8d56\u4e8e\u64cd\u4f5c\u6570\u7684\u6570\u636e\u7c7b\u578b\u3002<\/p>\n<\/p>\n<p><h4>1.1 \u5bf9\u6574\u6570\u8fdb\u884c\u52a0\u6cd5\u64cd\u4f5c<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">a = 10<\/p>\n<p>b = 20<\/p>\n<p>result = a + b<\/p>\n<p>print(&quot;\u6574\u6570\u52a0\u6cd5\u7ed3\u679c:&quot;, result)  # \u8f93\u51fa\uff1a\u6574\u6570\u52a0\u6cd5\u7ed3\u679c: 30<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u5b9a\u4e49\u4e86\u4e24\u4e2a\u6574\u6570\u53d8\u91cf <code>a<\/code> \u548c <code>b<\/code>\uff0c\u7136\u540e\u5c06\u5b83\u4eec\u76f8\u52a0\u5e76\u5c06\u7ed3\u679c\u5b58\u50a8\u5728 <code>result<\/code> \u53d8\u91cf\u4e2d\u3002\u6700\u540e\uff0c\u6211\u4eec\u4f7f\u7528 <code>print<\/code> \u51fd\u6570\u8f93\u51fa\u7ed3\u679c\u3002<\/p>\n<\/p>\n<p><h4>1.2 \u5bf9\u6d6e\u70b9\u6570\u8fdb\u884c\u52a0\u6cd5\u64cd\u4f5c<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">a = 10.5<\/p>\n<p>b = 20.3<\/p>\n<p>result = a + b<\/p>\n<p>print(&quot;\u6d6e\u70b9\u6570\u52a0\u6cd5\u7ed3\u679c:&quot;, result)  # \u8f93\u51fa\uff1a\u6d6e\u70b9\u6570\u52a0\u6cd5\u7ed3\u679c: 30.8<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a\u4f8b\u5b50\u4e0e\u524d\u4e00\u4e2a\u7c7b\u4f3c\uff0c\u53ea\u662f\u8fd9\u6b21\u6211\u4eec\u4f7f\u7528\u7684\u662f\u6d6e\u70b9\u6570\u3002\u52a0\u6cd5\u64cd\u4f5c\u540c\u6837\u9002\u7528\uff0c\u5e76\u4e14\u7ed3\u679c\u4f1a\u662f\u6d6e\u70b9\u6570\u3002<\/p>\n<\/p>\n<p><h4>1.3 \u5bf9\u5b57\u7b26\u4e32\u8fdb\u884c\u52a0\u6cd5\u64cd\u4f5c<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">str1 = &quot;Hello&quot;<\/p>\n<p>str2 = &quot; World&quot;<\/p>\n<p>result = str1 + str2<\/p>\n<p>print(&quot;\u5b57\u7b26\u4e32\u52a0\u6cd5\u7ed3\u679c:&quot;, result)  # \u8f93\u51fa\uff1a\u5b57\u7b26\u4e32\u52a0\u6cd5\u7ed3\u679c: Hello World<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u5c06\u4e24\u4e2a\u5b57\u7b26\u4e32\u76f8\u52a0\uff0c\u5b9e\u9645\u4e0a\u662f\u5c06\u5b83\u4eec\u8fde\u63a5\u5728\u4e00\u8d77\u3002\u8fd9\u79cd\u64cd\u4f5c\u4e5f\u79f0\u4e3a\u5b57\u7b26\u4e32\u62fc\u63a5\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u4f7f\u7528\u51cf\u53f7\uff08-\uff09\u8fdb\u884c\u51cf\u6cd5<\/h3>\n<\/p>\n<p><p>\u51cf\u6cd5\u64cd\u4f5c\u4e0e\u52a0\u6cd5\u64cd\u4f5c\u7c7b\u4f3c\uff0c\u53ea\u9700\u4f7f\u7528\u51cf\u53f7\uff08-\uff09\u5373\u53ef\u3002\u51cf\u6cd5\u64cd\u4f5c\u540c\u6837\u9002\u7528\u4e8e\u6574\u6570\u548c\u6d6e\u70b9\u6570\u3002<\/p>\n<\/p>\n<p><h4>2.1 \u5bf9\u6574\u6570\u8fdb\u884c\u51cf\u6cd5\u64cd\u4f5c<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">a = 20<\/p>\n<p>b = 10<\/p>\n<p>result = a - b<\/p>\n<p>print(&quot;\u6574\u6570\u51cf\u6cd5\u7ed3\u679c:&quot;, result)  # \u8f93\u51fa\uff1a\u6574\u6570\u51cf\u6cd5\u7ed3\u679c: 10<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u5b9a\u4e49\u4e86\u4e24\u4e2a\u6574\u6570\u53d8\u91cf <code>a<\/code> \u548c <code>b<\/code>\uff0c\u7136\u540e\u5c06 <code>a<\/code> \u51cf\u53bb <code>b<\/code> \u5e76\u5c06\u7ed3\u679c\u5b58\u50a8\u5728 <code>result<\/code> \u53d8\u91cf\u4e2d\u3002\u6700\u540e\uff0c\u6211\u4eec\u4f7f\u7528 <code>print<\/code> \u51fd\u6570\u8f93\u51fa\u7ed3\u679c\u3002<\/p>\n<\/p>\n<p><h4>2.2 \u5bf9\u6d6e\u70b9\u6570\u8fdb\u884c\u51cf\u6cd5\u64cd\u4f5c<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">a = 20.5<\/p>\n<p>b = 10.3<\/p>\n<p>result = a - b<\/p>\n<p>print(&quot;\u6d6e\u70b9\u6570\u51cf\u6cd5\u7ed3\u679c:&quot;, result)  # \u8f93\u51fa\uff1a\u6d6e\u70b9\u6570\u51cf\u6cd5\u7ed3\u679c: 10.2<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a\u4f8b\u5b50\u4e0e\u524d\u4e00\u4e2a\u7c7b\u4f3c\uff0c\u53ea\u662f\u8fd9\u6b21\u6211\u4eec\u4f7f\u7528\u7684\u662f\u6d6e\u70b9\u6570\u3002\u51cf\u6cd5\u64cd\u4f5c\u540c\u6837\u9002\u7528\uff0c\u5e76\u4e14\u7ed3\u679c\u4f1a\u662f\u6d6e\u70b9\u6570\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u786e\u4fdd\u6570\u636e\u7c7b\u578b<\/h3>\n<\/p>\n<p><p>\u5728\u8fdb\u884c\u52a0\u51cf\u64cd\u4f5c\u65f6\uff0c\u786e\u4fdd\u64cd\u4f5c\u6570\u7684\u6570\u636e\u7c7b\u578b\u662f\u517c\u5bb9\u7684\u975e\u5e38\u91cd\u8981\u3002\u5426\u5219\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u9519\u8bef\u3002\u4f8b\u5982\uff0c\u4e0d\u80fd\u76f4\u63a5\u5c06\u5b57\u7b26\u4e32\u4e0e\u6574\u6570\u76f8\u52a0\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">a = &quot;10&quot;<\/p>\n<p>b = 20<\/p>\n<h2><strong>result = a + b  # \u8fd9\u4f1a\u5bfc\u81f4\u9519\u8bef\uff1aTypeError: can only concatenate str (not &quot;int&quot;) to str<\/strong><\/h2>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e3a\u4e86\u907f\u514d\u8fd9\u79cd\u9519\u8bef\uff0c\u53ef\u4ee5\u5c06\u4e0d\u540c\u6570\u636e\u7c7b\u578b\u8f6c\u6362\u4e3a\u517c\u5bb9\u7684\u6570\u636e\u7c7b\u578b\u3002\u4f8b\u5982\uff0c\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u6574\u6570\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">a = &quot;10&quot;<\/p>\n<p>b = 20<\/p>\n<p>result = int(a) + b<\/p>\n<p>print(&quot;\u7c7b\u578b\u8f6c\u6362\u540e\u7684\u52a0\u6cd5\u7ed3\u679c:&quot;, result)  # \u8f93\u51fa\uff1a\u7c7b\u578b\u8f6c\u6362\u540e\u7684\u52a0\u6cd5\u7ed3\u679c: 30<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7c7b\u4f3c\u5730\uff0c\u4f60\u53ef\u4ee5\u5c06\u6574\u6570\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\uff0c\u4ee5\u4fbf\u8fdb\u884c\u5b57\u7b26\u4e32\u62fc\u63a5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">a = 10<\/p>\n<p>b = &quot;20&quot;<\/p>\n<p>result = str(a) + b<\/p>\n<p>print(&quot;\u7c7b\u578b\u8f6c\u6362\u540e\u7684\u5b57\u7b26\u4e32\u62fc\u63a5\u7ed3\u679c:&quot;, result)  # \u8f93\u51fa\uff1a\u7c7b\u578b\u8f6c\u6362\u540e\u7684\u5b57\u7b26\u4e32\u62fc\u63a5\u7ed3\u679c: 1020<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u901a\u8fc7\u53d8\u91cf\u5b58\u50a8\u7ed3\u679c<\/h3>\n<\/p>\n<p><p>\u5728\u8fdb\u884c\u52a0\u51cf\u64cd\u4f5c\u65f6\uff0c\u901a\u5e38\u4f1a\u5c06\u7ed3\u679c\u5b58\u50a8\u5728\u53d8\u91cf\u4e2d\uff0c\u4ee5\u4fbf\u540e\u7eed\u4f7f\u7528\u3002\u8fd9\u6709\u52a9\u4e8e\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u548c\u53ef\u7ef4\u62a4\u6027\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">a = 10<\/p>\n<p>b = 20<\/p>\n<p>sum_result = a + b<\/p>\n<p>diff_result = a - b<\/p>\n<p>print(&quot;\u52a0\u6cd5\u7ed3\u679c:&quot;, sum_result)  # \u8f93\u51fa\uff1a\u52a0\u6cd5\u7ed3\u679c: 30<\/p>\n<p>print(&quot;\u51cf\u6cd5\u7ed3\u679c:&quot;, diff_result)  # \u8f93\u51fa\uff1a\u51cf\u6cd5\u7ed3\u679c: -10<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u5c06\u52a0\u6cd5\u548c\u51cf\u6cd5\u7684\u7ed3\u679c\u5206\u522b\u5b58\u50a8\u5728 <code>sum_result<\/code> \u548c <code>diff_result<\/code> \u53d8\u91cf\u4e2d\u3002\u7136\u540e\uff0c\u6211\u4eec\u4f7f\u7528 <code>print<\/code> \u51fd\u6570\u8f93\u51fa\u8fd9\u4e9b\u7ed3\u679c\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u7ed3\u5408\u7528\u6237\u8f93\u5165\u8fdb\u884c\u52a0\u51cf\u64cd\u4f5c<\/h3>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u7ed3\u5408\u7528\u6237\u8f93\u5165\u8fdb\u884c\u52a0\u51cf\u64cd\u4f5c\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528 <code>input<\/code> \u51fd\u6570\u83b7\u53d6\u7528\u6237\u8f93\u5165\uff0c\u5e76\u5c06\u5176\u8f6c\u6362\u4e3a\u9002\u5f53\u7684\u6570\u636e\u7c7b\u578b\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">a = int(input(&quot;\u8bf7\u8f93\u5165\u7b2c\u4e00\u4e2a\u6574\u6570: &quot;))<\/p>\n<p>b = int(input(&quot;\u8bf7\u8f93\u5165\u7b2c\u4e8c\u4e2a\u6574\u6570: &quot;))<\/p>\n<p>sum_result = a + b<\/p>\n<p>diff_result = a - b<\/p>\n<p>print(&quot;\u52a0\u6cd5\u7ed3\u679c:&quot;, sum_result)<\/p>\n<p>print(&quot;\u51cf\u6cd5\u7ed3\u679c:&quot;, diff_result)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528 <code>input<\/code> \u51fd\u6570\u83b7\u53d6\u4e24\u4e2a\u6574\u6570\u8f93\u5165\uff0c\u5e76\u5c06\u5b83\u4eec\u8f6c\u6362\u4e3a\u6574\u6570\u7c7b\u578b\u3002\u7136\u540e\uff0c\u6211\u4eec\u8fdb\u884c\u52a0\u6cd5\u548c\u51cf\u6cd5\u64cd\u4f5c\uff0c\u5e76\u8f93\u51fa\u7ed3\u679c\u3002<\/p>\n<\/p>\n<p><h3>\u516d\u3001\u7ed3\u5408\u6761\u4ef6\u5224\u65ad\u8fdb\u884c\u52a0\u51cf\u64cd\u4f5c<\/h3>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u6839\u636e\u67d0\u4e9b\u6761\u4ef6\u8fdb\u884c\u52a0\u51cf\u64cd\u4f5c\u3002\u8fd9\u65f6\u53ef\u4ee5\u4f7f\u7528\u6761\u4ef6\u5224\u65ad\u8bed\u53e5\uff08\u5982 <code>if<\/code> \u8bed\u53e5\uff09\u6765\u5b9e\u73b0\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">a = int(input(&quot;\u8bf7\u8f93\u5165\u7b2c\u4e00\u4e2a\u6574\u6570: &quot;))<\/p>\n<p>b = int(input(&quot;\u8bf7\u8f93\u5165\u7b2c\u4e8c\u4e2a\u6574\u6570: &quot;))<\/p>\n<p>operation = input(&quot;\u8bf7\u8f93\u5165\u64cd\u4f5c\u7c7b\u578b\uff08+ \u6216 -\uff09: &quot;)<\/p>\n<p>if operation == &quot;+&quot;:<\/p>\n<p>    result = a + b<\/p>\n<p>elif operation == &quot;-&quot;:<\/p>\n<p>    result = a - b<\/p>\n<p>else:<\/p>\n<p>    result = &quot;\u65e0\u6548\u7684\u64cd\u4f5c\u7c7b\u578b&quot;<\/p>\n<p>print(&quot;\u7ed3\u679c:&quot;, result)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u6839\u636e\u7528\u6237\u8f93\u5165\u7684\u64cd\u4f5c\u7c7b\u578b\uff08\u52a0\u6cd5\u6216\u51cf\u6cd5\uff09\u6765\u51b3\u5b9a\u8fdb\u884c\u54ea\u79cd\u64cd\u4f5c\uff0c\u5e76\u8f93\u51fa\u7ed3\u679c\u3002<\/p>\n<\/p>\n<p><h3>\u4e03\u3001\u5728\u51fd\u6570\u4e2d\u8fdb\u884c\u52a0\u51cf\u64cd\u4f5c<\/h3>\n<\/p>\n<p><p>\u4e3a\u4e86\u4f7f\u4ee3\u7801\u66f4\u6a21\u5757\u5316\u548c\u53ef\u91cd\u7528\uff0c\u53ef\u4ee5\u5c06\u52a0\u51cf\u64cd\u4f5c\u5c01\u88c5\u5728\u51fd\u6570\u4e2d\u3002\u8fd9\u6709\u52a9\u4e8e\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u548c\u7ef4\u62a4\u6027\u3002<\/p>\n<\/p>\n<p><h4>7.1 \u5b9a\u4e49\u52a0\u6cd5\u51fd\u6570<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">def add(a, b):<\/p>\n<p>    return a + b<\/p>\n<p>result = add(10, 20)<\/p>\n<p>print(&quot;\u52a0\u6cd5\u51fd\u6570\u7ed3\u679c:&quot;, result)  # \u8f93\u51fa\uff1a\u52a0\u6cd5\u51fd\u6570\u7ed3\u679c: 30<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2a\u540d\u4e3a <code>add<\/code> \u7684\u51fd\u6570\uff0c\u8be5\u51fd\u6570\u63a5\u53d7\u4e24\u4e2a\u53c2\u6570\uff0c\u5e76\u8fd4\u56de\u5b83\u4eec\u7684\u548c\u3002\u7136\u540e\uff0c\u6211\u4eec\u8c03\u7528\u8be5\u51fd\u6570\u5e76\u8f93\u51fa\u7ed3\u679c\u3002<\/p>\n<\/p>\n<p><h4>7.2 \u5b9a\u4e49\u51cf\u6cd5\u51fd\u6570<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">def subtract(a, b):<\/p>\n<p>    return a - b<\/p>\n<p>result = subtract(20, 10)<\/p>\n<p>print(&quot;\u51cf\u6cd5\u51fd\u6570\u7ed3\u679c:&quot;, result)  # \u8f93\u51fa\uff1a\u51cf\u6cd5\u51fd\u6570\u7ed3\u679c: 10<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a\u4f8b\u5b50\u4e0e\u524d\u4e00\u4e2a\u7c7b\u4f3c\uff0c\u53ea\u662f\u8fd9\u6b21\u6211\u4eec\u5b9a\u4e49\u7684\u662f\u4e00\u4e2a\u51cf\u6cd5\u51fd\u6570\u3002<\/p>\n<\/p>\n<p><h3>\u516b\u3001\u7ed3\u5408\u5faa\u73af\u8fdb\u884c\u52a0\u51cf\u64cd\u4f5c<\/h3>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u5728\u5faa\u73af\u4e2d\u8fdb\u884c\u52a0\u51cf\u64cd\u4f5c\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528 <code>for<\/code> \u5faa\u73af\u6216 <code>while<\/code> \u5faa\u73af\u6765\u5b9e\u73b0\u3002<\/p>\n<\/p>\n<p><h4>8.1 \u4f7f\u7528 <code>for<\/code> \u5faa\u73af\u8fdb\u884c\u52a0\u6cd5\u64cd\u4f5c<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">numbers = [1, 2, 3, 4, 5]<\/p>\n<p>sum_result = 0<\/p>\n<p>for num in numbers:<\/p>\n<p>    sum_result += num<\/p>\n<p>print(&quot;for \u5faa\u73af\u52a0\u6cd5\u7ed3\u679c:&quot;, sum_result)  # \u8f93\u51fa\uff1afor \u5faa\u73af\u52a0\u6cd5\u7ed3\u679c: 15<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2a\u5305\u542b\u6574\u6570\u7684\u5217\u8868\uff0c\u5e76\u4f7f\u7528 <code>for<\/code> \u5faa\u73af\u5c06\u5b83\u4eec\u4f9d\u6b21\u76f8\u52a0\u3002\u6700\u540e\uff0c\u6211\u4eec\u8f93\u51fa\u52a0\u6cd5\u7ed3\u679c\u3002<\/p>\n<\/p>\n<p><h4>8.2 \u4f7f\u7528 <code>while<\/code> \u5faa\u73af\u8fdb\u884c\u51cf\u6cd5\u64cd\u4f5c<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">numbers = [10, 2, 3, 4, 1]<\/p>\n<p>diff_result = numbers[0]<\/p>\n<p>i = 1<\/p>\n<p>while i &lt; len(numbers):<\/p>\n<p>    diff_result -= numbers[i]<\/p>\n<p>    i += 1<\/p>\n<p>print(&quot;while \u5faa\u73af\u51cf\u6cd5\u7ed3\u679c:&quot;, diff_result)  # \u8f93\u51fa\uff1awhile \u5faa\u73af\u51cf\u6cd5\u7ed3\u679c: 0<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2a\u5305\u542b\u6574\u6570\u7684\u5217\u8868\uff0c\u5e76\u4f7f\u7528 <code>while<\/code> \u5faa\u73af\u4f9d\u6b21\u51cf\u53bb\u5217\u8868\u4e2d\u7684\u5143\u7d20\u3002\u6700\u540e\uff0c\u6211\u4eec\u8f93\u51fa\u51cf\u6cd5\u7ed3\u679c\u3002<\/p>\n<\/p>\n<p><h3>\u4e5d\u3001\u7ed3\u5408\u5217\u8868\u548c\u5b57\u5178\u8fdb\u884c\u52a0\u51cf\u64cd\u4f5c<\/h3>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u5bf9\u5217\u8868\u6216\u5b57\u5178\u4e2d\u7684\u5143\u7d20\u8fdb\u884c\u52a0\u51cf\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<p><h4>9.1 \u5bf9\u5217\u8868\u5143\u7d20\u8fdb\u884c\u52a0\u6cd5\u64cd\u4f5c<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">numbers = [10, 20, 30, 40, 50]<\/p>\n<p>sum_result = sum(numbers)<\/p>\n<p>print(&quot;\u5217\u8868\u5143\u7d20\u52a0\u6cd5\u7ed3\u679c:&quot;, sum_result)  # \u8f93\u51fa\uff1a\u5217\u8868\u5143\u7d20\u52a0\u6cd5\u7ed3\u679c: 150<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u5185\u7f6e\u7684 <code>sum<\/code> \u51fd\u6570\u8ba1\u7b97\u5217\u8868\u5143\u7d20\u7684\u548c\uff0c\u5e76\u8f93\u51fa\u7ed3\u679c\u3002<\/p>\n<\/p>\n<p><h4>9.2 \u5bf9\u5b57\u5178\u5143\u7d20\u8fdb\u884c\u52a0\u6cd5\u64cd\u4f5c<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">grades = {&quot;Alice&quot;: 85, &quot;Bob&quot;: 90, &quot;Charlie&quot;: 78}<\/p>\n<p>sum_result = sum(grades.values())<\/p>\n<p>print(&quot;\u5b57\u5178\u5143\u7d20\u52a0\u6cd5\u7ed3\u679c:&quot;, sum_result)  # \u8f93\u51fa\uff1a\u5b57\u5178\u5143\u7d20\u52a0\u6cd5\u7ed3\u679c: 253<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528 <code>grades.values()<\/code> \u83b7\u53d6\u5b57\u5178\u4e2d\u6240\u6709\u503c\u7684\u5217\u8868\uff0c\u5e76\u4f7f\u7528 <code>sum<\/code> \u51fd\u6570\u8ba1\u7b97\u5b83\u4eec\u7684\u548c\u3002\u6700\u540e\uff0c\u6211\u4eec\u8f93\u51fa\u7ed3\u679c\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u3001\u7ed3\u5408\u5217\u8868\u89e3\u6790\u8fdb\u884c\u52a0\u51cf\u64cd\u4f5c<\/h3>\n<\/p>\n<p><p>\u5217\u8868\u89e3\u6790\u662f\u4e00\u79cd\u7b80\u6d01\u7684\u65b9\u5f0f\uff0c\u53ef\u4ee5\u5bf9\u5217\u8868\u4e2d\u7684\u5143\u7d20\u8fdb\u884c\u52a0\u51cf\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<p><h4>10.1 \u4f7f\u7528\u5217\u8868\u89e3\u6790\u8fdb\u884c\u52a0\u6cd5\u64cd\u4f5c<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">numbers = [1, 2, 3, 4, 5]<\/p>\n<p>sum_result = sum([num + 1 for num in numbers])<\/p>\n<p>print(&quot;\u5217\u8868\u89e3\u6790\u52a0\u6cd5\u7ed3\u679c:&quot;, sum_result)  # \u8f93\u51fa\uff1a\u5217\u8868\u89e3\u6790\u52a0\u6cd5\u7ed3\u679c: 20<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u5217\u8868\u89e3\u6790\u5bf9\u5217\u8868\u4e2d\u7684\u6bcf\u4e2a\u5143\u7d20\u52a0 1\uff0c\u5e76\u8ba1\u7b97\u5b83\u4eec\u7684\u548c\u3002\u6700\u540e\uff0c\u6211\u4eec\u8f93\u51fa\u7ed3\u679c\u3002<\/p>\n<\/p>\n<p><h4>10.2 \u4f7f\u7528\u5217\u8868\u89e3\u6790\u8fdb\u884c\u51cf\u6cd5\u64cd\u4f5c<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">numbers = [10, 20, 30, 40, 50]<\/p>\n<p>diff_result = numbers[0] - sum([num for num in numbers[1:]])<\/p>\n<p>print(&quot;\u5217\u8868\u89e3\u6790\u51cf\u6cd5\u7ed3\u679c:&quot;, diff_result)  # \u8f93\u51fa\uff1a\u5217\u8868\u89e3\u6790\u51cf\u6cd5\u7ed3\u679c: -130<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u5217\u8868\u89e3\u6790\u8ba1\u7b97\u5217\u8868\u4e2d\u6240\u6709\u5143\u7d20\u7684\u548c\uff08\u9664\u4e86\u7b2c\u4e00\u4e2a\u5143\u7d20\uff09\uff0c\u7136\u540e\u5c06\u7b2c\u4e00\u4e2a\u5143\u7d20\u51cf\u53bb\u8fd9\u4e2a\u548c\u3002\u6700\u540e\uff0c\u6211\u4eec\u8f93\u51fa\u7ed3\u679c\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u4e00\u3001\u7ed3\u5408\u751f\u6210\u5668\u8868\u8fbe\u5f0f\u8fdb\u884c\u52a0\u51cf\u64cd\u4f5c<\/h3>\n<\/p>\n<p><p>\u751f\u6210\u5668\u8868\u8fbe\u5f0f\u662f\u4e00\u79cd\u9ad8\u6548\u7684\u65b9\u5f0f\uff0c\u53ef\u4ee5\u5bf9\u5927\u91cf\u6570\u636e\u8fdb\u884c\u52a0\u51cf\u64cd\u4f5c\uff0c\u800c\u4e0d\u4f1a\u5360\u7528\u8fc7\u591a\u7684\u5185\u5b58\u3002<\/p>\n<\/p>\n<p><h4>11.1 \u4f7f\u7528\u751f\u6210\u5668\u8868\u8fbe\u5f0f\u8fdb\u884c\u52a0\u6cd5\u64cd\u4f5c<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">numbers = (1, 2, 3, 4, 5)<\/p>\n<p>sum_result = sum(num + 1 for num in numbers)<\/p>\n<p>print(&quot;\u751f\u6210\u5668\u8868\u8fbe\u5f0f\u52a0\u6cd5\u7ed3\u679c:&quot;, sum_result)  # \u8f93\u51fa\uff1a\u751f\u6210\u5668\u8868\u8fbe\u5f0f\u52a0\u6cd5\u7ed3\u679c: 20<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u751f\u6210\u5668\u8868\u8fbe\u5f0f\u5bf9\u751f\u6210\u5668\u4e2d\u7684\u6bcf\u4e2a\u5143\u7d20\u52a0 1\uff0c\u5e76\u8ba1\u7b97\u5b83\u4eec\u7684\u548c\u3002\u6700\u540e\uff0c\u6211\u4eec\u8f93\u51fa\u7ed3\u679c\u3002<\/p>\n<\/p>\n<p><h4>11.2 \u4f7f\u7528\u751f\u6210\u5668\u8868\u8fbe\u5f0f\u8fdb\u884c\u51cf\u6cd5\u64cd\u4f5c<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">numbers = (10, 20, 30, 40, 50)<\/p>\n<p>diff_result = next(numbers) - sum(num for num in numbers)<\/p>\n<p>print(&quot;\u751f\u6210\u5668\u8868\u8fbe\u5f0f\u51cf\u6cd5\u7ed3\u679c:&quot;, diff_result)  # \u8f93\u51fa\uff1a\u751f\u6210\u5668\u8868\u8fbe\u5f0f\u51cf\u6cd5\u7ed3\u679c: -130<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u751f\u6210\u5668\u8868\u8fbe\u5f0f\u8ba1\u7b97\u751f\u6210\u5668\u4e2d\u6240\u6709\u5143\u7d20\u7684\u548c\uff08\u9664\u4e86\u7b2c\u4e00\u4e2a\u5143\u7d20\uff09\uff0c\u7136\u540e\u5c06\u7b2c\u4e00\u4e2a\u5143\u7d20\u51cf\u53bb\u8fd9\u4e2a\u548c\u3002\u6700\u540e\uff0c\u6211\u4eec\u8f93\u51fa\u7ed3\u679c\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u4e8c\u3001\u7ed3\u5408NumPy\u5e93\u8fdb\u884c\u52a0\u51cf\u64cd\u4f5c<\/h3>\n<\/p>\n<p><p>NumPy \u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u6570\u503c\u8ba1\u7b97\u5e93\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u8fdb\u884c\u52a0\u51cf\u64cd\u4f5c\uff0c\u7279\u522b\u662f\u5bf9\u5927\u89c4\u6a21\u6570\u636e\u3002<\/p>\n<\/p>\n<p><h4>12.1 \u4f7f\u7528NumPy\u8fdb\u884c\u52a0\u6cd5\u64cd\u4f5c<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<p>a = np.array([1, 2, 3, 4, 5])<\/p>\n<p>b = np.array([5, 4, 3, 2, 1])<\/p>\n<p>sum_result = a + b<\/p>\n<p>print(&quot;NumPy\u52a0\u6cd5\u7ed3\u679c:&quot;, sum_result)  # \u8f93\u51fa\uff1aNumPy\u52a0\u6cd5\u7ed3\u679c: [6 6 6 6 6]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528NumPy\u5e93\u5b9a\u4e49\u4e24\u4e2a\u6570\u7ec4\uff0c\u5e76\u5bf9\u5b83\u4eec\u8fdb\u884c\u52a0\u6cd5\u64cd\u4f5c\u3002\u6700\u540e\uff0c\u6211\u4eec\u8f93\u51fa\u7ed3\u679c\u3002<\/p>\n<\/p>\n<p><h4>12.2 \u4f7f\u7528NumPy\u8fdb\u884c\u51cf\u6cd5\u64cd\u4f5c<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<p>a = np.array([10, 20, 30, 40, 50])<\/p>\n<p>b = np.array([1, 2, 3, 4, 5])<\/p>\n<p>diff_result = a - b<\/p>\n<p>print(&quot;NumPy\u51cf\u6cd5\u7ed3\u679c:&quot;, diff_result)  # \u8f93\u51fa\uff1aNumPy\u51cf\u6cd5\u7ed3\u679c: [ 9 18 27 36 45]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528NumPy\u5e93\u5b9a\u4e49\u4e24\u4e2a\u6570\u7ec4\uff0c\u5e76\u5bf9\u5b83\u4eec\u8fdb\u884c\u51cf\u6cd5\u64cd\u4f5c\u3002\u6700\u540e\uff0c\u6211\u4eec\u8f93\u51fa\u7ed3\u679c\u3002<\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u65b9\u6cd5\uff0c\u4f60\u53ef\u4ee5\u5728Python\u7a0b\u5e8f\u4e2d\u7075\u6d3b\u5730\u8fdb\u884c\u52a0\u51cf\u64cd\u4f5c\u3002\u65e0\u8bba\u662f\u57fa\u672c\u7684\u7b97\u672f\u8fd0\u7b97\uff0c\u8fd8\u662f\u7ed3\u5408\u6761\u4ef6\u5224\u65ad\u3001\u5faa\u73af\u3001\u5217\u8868\u89e3\u6790\u3001\u751f\u6210\u5668\u8868\u8fbe\u5f0f\uff0c\u751a\u81f3\u4f7f\u7528NumPy\u5e93\uff0c\u4f60\u90fd\u53ef\u4ee5\u627e\u5230\u9002\u5408\u4f60\u7684\u573a\u666f\u548c\u9700\u6c42\u7684\u65b9\u6cd5\u3002\u5e0c\u671b\u8fd9\u4e9b\u793a\u4f8b\u80fd\u5e2e\u52a9\u4f60\u66f4\u597d\u5730\u7406\u89e3\u548c\u5e94\u7528Python\u4e2d\u7684\u52a0\u51cf\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u8fdb\u884c\u57fa\u672c\u7684\u52a0\u51cf\u8fd0\u7b97\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u52a0\u51cf\u8fd0\u7b97\u53ef\u4ee5\u901a\u8fc7\u7b80\u5355\u7684\u8fd0\u7b97\u7b26\u5b9e\u73b0\u3002\u4f7f\u7528\u201c+\u201d\u8fdb\u884c\u52a0\u6cd5\uff0c\u4f7f\u7528\u201c-\u201d\u8fdb\u884c\u51cf\u6cd5\u3002\u4f8b\u5982\uff0c\u5982\u679c\u4f60\u60f3\u8ba1\u7b97\u4e24\u4e2a\u6570\u5b57\u7684\u548c\uff0c\u53ef\u4ee5\u8fd9\u6837\u5199\uff1a<code>result = a + b<\/code>\uff0c\u800c\u51cf\u6cd5\u5219\u662f<code>result = a - b<\/code>\u3002\u8fd9\u4e24\u4e2a\u64cd\u4f5c\u90fd\u53ef\u4ee5\u76f4\u63a5\u5728Python\u7684\u547d\u4ee4\u884c\u6216\u4efb\u4f55Python\u6587\u4ef6\u4e2d\u6267\u884c\u3002<\/p>\n<p><strong>\u5728Python\u4e2d\u5982\u4f55\u5904\u7406\u6d6e\u70b9\u6570\u7684\u52a0\u51cf\uff1f<\/strong><br \/>\u5904\u7406\u6d6e\u70b9\u6570\u65f6\uff0cPython\u540c\u6837\u652f\u6301\u52a0\u51cf\u8fd0\u7b97\u3002\u4f8b\u5982\uff0c<code>result = 5.5 + 2.3<\/code>\u5c06\u8fd4\u56de7.8\uff0c<code>result = 5.5 - 2.3<\/code>\u5c06\u8fd4\u56de3.2\u3002\u5728\u8fdb\u884c\u6d6e\u70b9\u6570\u8fd0\u7b97\u65f6\uff0c\u8981\u6ce8\u610f\u53ef\u80fd\u51fa\u73b0\u7684\u7cbe\u5ea6\u95ee\u9898\uff0c\u5efa\u8bae\u4f7f\u7528<code>round()<\/code>\u51fd\u6570\u6765\u63a7\u5236\u7ed3\u679c\u7684\u5c0f\u6570\u4f4d\u6570\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Python\u7a0b\u5e8f\u4e2d\u5b9e\u73b0\u7528\u6237\u8f93\u5165\u7684\u52a0\u51cf\u8fd0\u7b97\uff1f<\/strong><br \/>\u8981\u5b9e\u73b0\u7528\u6237\u8f93\u5165\u7684\u52a0\u51cf\u8fd0\u7b97\uff0c\u53ef\u4ee5\u4f7f\u7528<code>input()<\/code>\u51fd\u6570\u83b7\u53d6\u7528\u6237\u8f93\u5165\uff0c\u5e76\u5c06\u5176\u8f6c\u6362\u4e3a\u6570\u5b57\u3002\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a  <\/p>\n<pre><code class=\"language-python\">a = float(input(&quot;\u8bf7\u8f93\u5165\u7b2c\u4e00\u4e2a\u6570\u5b57\uff1a&quot;))\nb = float(input(&quot;\u8bf7\u8f93\u5165\u7b2c\u4e8c\u4e2a\u6570\u5b57\uff1a&quot;))\nprint(&quot;\u52a0\u6cd5\u7ed3\u679c\uff1a&quot;, a + b)\nprint(&quot;\u51cf\u6cd5\u7ed3\u679c\uff1a&quot;, a - b)\n<\/code><\/pre>\n<p>\u8fd9\u6837\uff0c\u7528\u6237\u53ef\u4ee5\u8f93\u5165\u4efb\u610f\u6570\u5b57\uff0c\u7a0b\u5e8f\u5c06\u8f93\u51fa\u76f8\u5e94\u7684\u52a0\u51cf\u7ed3\u679c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python\u7a0b\u5e8f\u4e2d\u5982\u4f55\u8fdb\u884c\u52a0\u51cf\u64cd\u4f5c \u5728Python\u7a0b\u5e8f\u4e2d\u8fdb\u884c\u52a0\u51cf\u64cd\u4f5c\u975e\u5e38\u7b80\u5355\uff0c\u4e3b\u8981\u901a\u8fc7\u57fa\u672c\u7684\u7b97\u672f\u8fd0\u7b97\u7b26\u6765\u5b9e\u73b0\u3002 [&hellip;]","protected":false},"author":3,"featured_media":1109914,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1109911"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=1109911"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1109911\/revisions"}],"predecessor-version":[{"id":1109915,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1109911\/revisions\/1109915"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1109914"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1109911"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1109911"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1109911"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}