{"id":603,"date":"2017-12-05T18:15:03","date_gmt":"2017-12-05T10:15:03","guid":{"rendered":"http:\/\/cflin.com\/wordpress\/?p=603"},"modified":"2017-12-05T18:20:49","modified_gmt":"2017-12-05T10:20:49","slug":"pep8-python%e7%b7%a8%e7%a2%bc%e8%a6%8f%e7%af%84%e6%89%8b%e5%86%8a","status":"publish","type":"post","link":"https:\/\/cflin.com\/wordpress\/603\/pep8-python%e7%b7%a8%e7%a2%bc%e8%a6%8f%e7%af%84%e6%89%8b%e5%86%8a","title":{"rendered":"PEP8 Python \u7de8\u78bc\u898f\u7bc4\u624b\u518a"},"content":{"rendered":"<h1>PEP 8 \u4ecb\u7d39<\/h1>\n<p><a href=\"http:\/\/legacy.python.org\/dev\/peps\/pep-0008\/\">PEP8<\/a>\u00a0\u662f Python \u793e\u7fa4\u5171\u901a\u7684\u98a8\u683c\u6307\u5357\uff0c\u4e00\u958b\u59cb\u662f Python \u4e4b\u7236 Guido van Rossum \u81ea\u5df1\u7684\u64b0\u78bc\u98a8\u683c\uff0c\u6162\u6162\u5f8c\u4f86\u6f14\u8b8a\u81f3\u4eca\uff0c\u76ee\u7684\u5728\u65bc\u5e6b\u52a9\u958b\u767c\u8005\u5beb\u51fa\u53ef\u8b80\u6027\u9ad8\u4e14\u98a8\u683c\u4e00\u81f4\u7684\u7a0b\u5f0f\u3002\u8a31\u591a\u958b\u6e90\u8a08\u756b\uff0c\u4f8b\u5982\u00a0<a href=\"https:\/\/docs.djangoproject.com\/en\/1.6\/internals\/contributing\/writing-code\/coding-style\/\">Django<\/a>\u00a0\u3001\u00a0<a href=\"http:\/\/docs.openstack.org\/developer\/hacking\/\">OpenStack<\/a>\u7b49\u90fd\u662f\u4ee5 PEP8 \u70ba\u57fa\u790e\u518d\u52a0\u4e0a\u81ea\u5df1\u7684\u98a8\u683c\u5efa\u8b70\u3002<\/p>\n<h2>\u7a0b\u5f0f\u78bc\u7de8\u6392 (Code lay-out)<\/h2>\n<p>\u9019\u908a\u5217\u51faPEP8\u88e1\u9762\u7684\u91cd\u9ede\uff0c\u6709\u8208\u8da3\u53ef\u4ee5\u76f4\u63a5\u770b\u5b98\u65b9\u539f\u6587\u7684\u6587\u4ef6\u6703\u66f4\u6e05\u695a\u4e00\u4e9b\u3002<\/p>\n<p><strong>\u7e2e\u6392 (Indentation)<\/strong><br \/>\n\u6bcf\u5c64\u7e2e\u6392\u4f7f\u7528 4 \u500b\u7a7a\u683c<\/p>\n<p><strong>\u65b7\u884c\u98a8\u683c<\/strong><br \/>\n\u6b63\u78ba\uff1a<br \/>\n# \u65b7\u884c\u9996\u5b57\u6bcd\u8207\u958b\u982d\u7684\u62ec\u865f\u5782\u76f4\u5c0d\u9f4a.<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nfoo = long_function_name(var_one, var_two,\r\n                         var_three, var_four)\r\n<\/pre>\n<p># \u5782\u76f4\u7e2e\u6392\uff0c\u9996\u884c\u4e0d\u80fd\u6709\u53c3\u6578.<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\ndef long_function_name(\r\n        var_one, var_two, var_three,\r\n        var_four):\r\n    print(var_one)\r\n<\/pre>\n<p># \u5782\u76f4\u7e2e\u6392\uff0c\u5f8c\u9762\u9084\u6709\u5176\u5b83\u4ee3\u78bc\u6642\uff0c\u9700\u8981\u6dfb\u52a0\u4e00\u5c64\u984d\u5916\u7684\u7e2e\u6392\u52a0\u4ee5\u5340\u5225\uff1a<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nfoo = long_function_name(\r\n    var_one, var_two,\r\n    var_three, var_four)\r\n<\/pre>\n<p>\u932f\u8aa4\uff1a<br \/>\n# \u5782\u76f4\u7e2e\u6392\u65b9\u5f0f\u9996\u884c\u4e0d\u80fd\u6709\u5f15\u6578<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nfoo = long_function_name(var_one, var_two,\r\n    var_three, var_four)\r\n<\/pre>\n<p># \u5782\u76f4\u7e2e\u6392\uff0c\u9996\u884c\u4e0d\u80fd\u6709\u53c3\u6578; \u5f8c\u9762\u9084\u6709\u5176\u5b83\u4ee3\u78bc\u90e8\u5206\u6642\uff0c\u65b7\u884c\u8981\u6dfb\u52a0\u4e00\u5c64\u7e2e\u9032\uff0c\u4f7f\u5176\u8207\u5176\u5b83\u4ee3\u78bc\u90e8\u5206\u80fd\u5340\u5225\u958b\u4f86<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\ndef long_function_name(\r\n    var_one, var_two, var_three,\r\n    var_four):\r\n    print(var_one)\r\n<\/pre>\n<p><strong>if \u689d\u4ef6\u65b7\u884c<\/strong><br \/>\n<span style=\"color: #ff0000;\">if (<\/span> \u525b\u597d\u6709 4 \u500b\u5b57\u7b26\uff0c\u76f8\u7576\u65bc\u4e00\u5c64\u7e2e\u6392\u3002<br \/>\n\u5c0d\u65bc if \u689d\u4ef6\u65b7\u884c\uff0c\u4ee5\u4e0b\u5e7e\u7a2e\u98a8\u683c\u90fd\u53ef\u4ee5\uff1a<br \/>\n\u6c92\u6709\u984d\u5916\u7684\u7e2e\u6392<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nif (this_is_one_thing and\r\n    that_is_another_thing):\r\n    do_something()\r\n<\/pre>\n<p>\u6dfb\u52a0\u8a3b\u91cb\u52a0\u4ee5\u5340\u5206<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n# Add a comment, which will provide some distinction in editors\r\n# supporting syntax highlighting.\r\nif (this_is_one_thing and\r\n    that_is_another_thing):\r\n    # Since both conditions are true, we can frobnicate.\r\n    do_something()\r\n<\/pre>\n<p>\u6dfb\u52a0\u984d\u5916\u7684\u7e2e\u6392\u52a0\u4ee5\u5340\u5206<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n# Add some extra indentation on the conditional continuation line.\r\nif (this_is_one_thing\r\n        and that_is_another_thing):\r\n    do_something()\r\n<\/pre>\n<h3><strong>\u591a\u884c\u7684\u62ec\u865f<\/strong><\/h3>\n<p>\u62ec\u865f\u7d50\u675f\u7b26\u8207\u6700\u5f8c\u884c\u7684\u9996\u5b57\u7b26\u5c0d\u9f4a\uff0c\u5982\uff1a<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nmy_list = [\r\n    1, 2, 3,\r\n    4, 5, 6,\r\n    ]\r\n\r\nresult = some_function_that_takes_arguments(\r\n    'a', 'b', 'c',\r\n    'd', 'e', 'f',\r\n    )\r\n<\/pre>\n<p>\u62ec\u865f\u7d50\u675f\u7b26\u8207\u9996\u884c\u7684\u9996\u5b57\u7b26\u5c0d\u9f4a, \u5982\uff1a<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nmy_list = [\r\n    1, 2, 3,\r\n    4, 5, 6,\r\n]\r\nresult = some_function_that_takes_arguments(\r\n    'a', 'b', 'c',\r\n    'd', 'e', 'f',\r\n)\r\n<\/pre>\n<p>\u4e0a\u9762\u5169\u7a2e\u6392\u7248\u7684\u65b9\u5f0f\u90fd\u53ef\u4ee5<\/p>\n<h3><strong>\u4f7f\u7528Tab\u9084\u662f\u7a7a\u683c\u7e2e\u6392<\/strong><\/h3>\n<p>\u7528\u7a7a\u683c<\/p>\n<h4><strong>\u6bcf\u884c\u6700\u9577\u9577\u5ea6<\/strong><\/h4>\n<p>\u6240\u6709\u884c\u90fd\u4e0d\u8d85\u904e 80 \u500b\u5b57\u7b26<\/p>\n<p>\u9650\u5236\u7de8\u8f2f\u5668\u8996\u7a97\u7684\u5bec\u5ea6\uff0c\u4f7f\u80fd\u4e26\u6392\u540c\u6642\u6253\u958b\u591a\u500b\u6587\u4ef6\u3002<br \/>\n\u8a2d\u7f6e\u7de8\u8f2f\u5668\u5bec\u5ea6(set width to 80)\uff0c\u4f86\u907f\u514d wrapping<br \/>\n\u5c0d\u65bc\u8f03\u5c11\u7d50\u69cb\u9650\u5236\u7684\u9577\u6587\u672c\uff08\u5982 docstrings \u6216\u8a3b\u91cb\uff09\uff0c\u884c\u9577\u61c9\u9650\u5236\u70ba 72 \u500b\u5b57\u7b26\u3002<br \/>\n\u5982\u679c\u5718\u968a\u6210\u54e1\u90fd\u540c\u610f\u4f7f\u7528\u9577\u884c\uff0c\u5247\u53ef\u4ee5\u5c07\u884c\u9577\u589e\u52a0\u5230\u4e0d\u8d85\u904e 100 \u500b\u5b57\u7b26\uff0c\u4f46\u662f docstrings \u548c\u8a3b\u91cb\u9084\u5fc5\u9808\u70ba 72 \u500b\u5b57\u7b26\u3002<\/p>\n<p>\u6709\u62ec\u865f\u7684\u9577\u884c\u53ef\u4ee5\u7528 implicit continuation \u4f86\u65b7\u884c\uff0c\u5176\u5b83\u7684\u53ef\u4ee5\u7528 \\ \u4f86\u65b7\u884c\uff0c\u5982\uff1a<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nwith open('\/path\/to\/some\/file\/you\/want\/to\/read') as file_1, \\\r\n     open('\/path\/to\/some\/file\/being\/written', 'w') as file_2:\r\n    file_2.write(file_1.read())\r\n<\/pre>\n<h4><strong>\u64cd\u4f5c\u7b26\u8981\u548c\u64cd\u4f5c\u6578\u5728\u4e00\u8d77<\/strong><\/h4>\n<p># \u63a8\u85a6\u7684\u6b63\u78ba\u7684\u98a8\u683c\uff0c\u9019\u6a23\u5f88\u5bb9\u6613\u5c07\u64cd\u4f5c\u7b26\u8207\u64cd\u4f5c\u6578\u5339\u914d\uff1a<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nincome = (gross_wages\r\n          + taxable_interest\r\n          + (dividends - qualified_dividends)\r\n          - ira_deduction\r\n          - student_loan_interest)\r\n<\/pre>\n<p># \u9019\u7a2e\u98a8\u683c\u73fe\u4eca\u5df2\u4e0d\u63a8\u85a6\u4f7f\u7528\u4e86\uff1a<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nincome = (gross_wages +\r\n          taxable_interest +\r\n          (dividends - qualified_dividends) -\r\n          ira_deduction -\r\n          student_loan_interest)\r\n<\/pre>\n<h4><strong>\u7a7a\u884c\u5206\u9694<\/strong><\/h4>\n<p>\u6a21\u7d44\u4e2d\u6700\u9802\u5c64\u7684\u51fd\u6578\u548c\u985e\u5b9a\u7fa9\u90fd\u8981\u7528\u5169\u884c\u7a7a\u884c\u5206\u9694<br \/>\n\u985e\u5225\u4e2d\u7684\u65b9\u6cd5\u5b9a\u7fa9\u7528\u55ae\u884c\u5206\u9694<br \/>\n\u8981\u628a\u4e00\u7d44\u76f8\u95dc\u7684\u51fd\u6578\u5206\u7d44\uff0c\u53ef\u4ee5\u7528\u4e00\u4e9b\u984d\u5916\u7684\u7a7a\u884c<br \/>\n\u51fd\u6578\u4e2d\u7684\u908f\u8f2f\u5340\u584a\u53ef\u4ee5\u52a0\u7a7a\u884c\u4f86\u5206\u9694<\/p>\n<h4><strong>\u539f\u59cb\u78bc\u7684\u7de8\u78bc<\/strong><\/h4>\n<p>Python \u6838\u5fc3\u6a21\u7d44\u6587\u4ef6\u7684\u7de8\u78bc\u90fd\u5fc5\u9808\u7528 UTF-8\uff08Python2 \u662f ASCII)\u3002<br \/>\n\u4f7f\u7528\u9ed8\u8a8d\u7684\u7de8\u78bc\u6642\uff08Python3: UTF-8\uff0cPython2: ASCII)\uff0c\u4e0d\u80fd\u4f7f\u7528\u7de8\u78bc\u8072\u660e<br \/>\n\u6a19\u6e96\u5eab\u4e2d\uff0c\u53ea\u6709\u6e2c\u8a66\u3001\u4f5c\u8005\u540d\u624d\u80fd\u4f7f\u7528\u975e\u9ed8\u8a8d\u7684\u7de8\u78bc\uff0c\u5176\u5b83\u60c5\u6cc1\u4e0b\u7684\u975e ASCII \u5b57\u7b26\u7528 \\x, \\u, \\u, \\N \u8868\u793a\u6cd5\u8868\u793a\u3002<\/p>\n<h4><strong>Import<\/strong><\/h4>\n<p>\u6bcf\u884c import \u53ea\u5c0e\u5165\u4e00\u500b\u6a21\u7d44\uff1a<br \/>\n# \u6b63\u78ba:<br \/>\nimport os<br \/>\nimport sys<br \/>\n# \u932f\u8aa4\uff1a<br \/>\nimport sys, os<br \/>\n# \u6b63\u78ba\uff1a\u540c\u4e00\u6a21\u7d44\u4e2d\u7684\u5167\u5bb9\u53ef\u4ee5\u5728\u540c\u4e00\u884c\u5c0e\u5165<br \/>\nfrom subprocess import Popen, PIPE<\/p>\n<p>import \u8a9e\u53e5\u8981\u5728\u6587\u4ef6\u7684\u524d\u9762\uff0c\u5728\u6a21\u7d44\u8a3b\u91cb\u53ca docstrings \u4e4b\u5f8c\uff0c\u5728\u6a21\u7d44\u5168\u57df\u8b8a\u6578\u548c\u5e38\u6578\u5b9a\u7fa9\u4e4b\u524d\u3002<br \/>\nimport \u5206\u7d44\u53ca\u5c0e\u5165\u9806\u5e8f\uff0c\u6bcf\u500b\u5206\u7d44\u4e4b\u9593\u7528\u4e00\u884c\u7a7a\u884c\u5206\u9694 1. \u6a19\u6e96\u5eab 2. \u76f8\u95dc\u7b2c\u4e09\u65b9\u5eab 3. \u672c\u5730\u61c9\u7528\/\u5eab\u7684\u7279\u6b8a\u5c0e\u5165<br \/>\n\u63a8\u85a6\u4f7f\u7528\u7d55\u5c0d\u5c0e\u5165\uff0c\u5982\uff1a<br \/>\nimport mypkg.sibling<br \/>\nfrom mypkg import sibling<br \/>\nfrom mypkg.sibling import example<\/p>\n<p>\u5728\u6bd4\u8f03\u8986\u96dc\u7684\u5957\u4ef6\u7d44\u6210\u4e2d\uff0c\u4e5f\u53ef\u4ee5\u7528\u986f\u5f0f\u7684\u76f8\u5c0d\u5c0e\u5165\uff0c\u5982\uff1a<br \/>\nfrom . import sibling<br \/>\nfrom .sibling import example<br \/>\n\u5f9e\u4e00\u500b\u6a21\u584a\u4e2d\u5c0e\u5165\u4e00\u500b\u985e\u5225\u6642\uff0c\u8981\u986f\u793a\u62fc\u5beb\u51fa\u985e\u5225\u540d\uff0c\u5982\uff1a<br \/>\nfrom myclass import MyClass<br \/>\nfrom foo.bar.yourclass import YourClass<\/p>\n<p>\u5982\u679c\u8207\u672c\u5730\u540d\u7a31\u885d\u7a81\uff0c\u53ef\u4ee5\u5148\u5c0e\u5165\u6a21\u7d44\uff1a<br \/>\nimport myclass<br \/>\nimport foo.bar.yourclass<br \/>\n\u7136\u5f8c\u4f7f\u7528\uff1a\"myclass.MyClass\" \u548c &#8220;foo.bar.yourclass.YourClass\"\u3002<br \/>\n\u61c9\u8a72\u907f\u514d\u4f7f\u7528 from &lt;module&gt; import *<br \/>\n\u6a21\u7d44\u5c64\u7d1a\u7684\u7279\u6b8a\u540d\u7a31\uff08\u5982__all__)\u7684\u4f4d\u7f6e\uff1a<br \/>\n\u5fc5\u9808\u5728\u6a21\u7d44\u7684 docstrings \u6216\u8a3b\u91cb\u4e4b\u5f8c\uff0c\u4f46\u5728\u4efb\u4f55\u7684 import \u8a9e\u53e5\u4e4b\u524d\u3002from __future__ \u6bd4\u8f03\u7279\u6b8a\uff0cPython \u5f37\u5236\u8a72\u8a9e\u53e5\u5fc5\u9808\u5728 docstrings \u6216\u8a3b\u91cb\u4e4b\u5f8c\uff0c\u56e0\u6b64\u98a8\u683c\u5982\u4e0b\uff1a<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n&quot;&quot;&quot;This is the example module.\r\n\r\nThis module does stuff.\r\n&quot;&quot;&quot;\r\n\r\nfrom __future__ import barry_as_FLUFL\r\n\r\n__all__ = ['a', 'b', 'c']\r\n__version__ = '0.1'\r\n__author__ = 'Cardinal Biggles'\r\n\r\nimport os\r\nimport sys\r\n<\/pre>\n<h4><strong>\u5b57\u7b26\u5f15\u865f (String Quotes)<\/strong><\/h4>\n<p>\u55ae\u5f15\u865f\u548c\u96d9\u5f15\u865f\u7684\u529f\u80fd\u662f\u7b49\u540c\u7684\u3002<br \/>\n\u5c0d\u65bc\u591a\u884c\u5b57\u7b26\u4e32\uff0c\u61c9\u8a72\u7528\u96d9\u5f15\u865f\u5b57\u7b26\u5f62\u5f0f\u7684\u4e09\u5f15\u865f\"\"\"\uff0c\u4ee5\u4fbf\u8207 PEP257 \u4e2d\u7684 docstrings \u898f\u7bc4\u517c\u5bb9<\/p>\n<h4><strong>\u8868\u9054\u5f0f\u548c\u8a9e\u53e5\u4e2d\u7684\u7a7a\u683c (Whitespace in Expressions and Statements)<\/strong><\/h4>\n<p>()\u3001[]\u3001{} \u7b49\u62ec\u865f\u5167\u4e0d\u8981\u591a\u9918\u7684\u7a7a\u683c\uff0c\u5982\uff1a<br \/>\n# \u6b63\u78ba\uff1a<br \/>\nspam(ham[1], {eggs: 2})<br \/>\n# \u932f\u8aa4\uff1a<br \/>\nspam( ham[ 1 ], { eggs: 2 } )<br \/>\n,\u3001;\u3001: \u4e4b\u524d\u4e0d\u8981\u6709\u7a7a\u683c\uff0c\u5982\uff1a<br \/>\n# \u6b63\u78ba\uff1a<br \/>\nif x == 4: print x, y; x, y = y, x<br \/>\n# \u932f\u8aa4\uff1a<br \/>\nif x == 4 : print x , y ; x , y = y , x<br \/>\n\u5728 slice \u8a9e\u53e5\u4e2d\u7684 :\u5be6\u969b\u4e0a\u662f\u4e00\u500b\u4e8c\u5143\u64cd\u4f5c\u7b26\uff0c\u56e0\u6b64\u5176\u5169\u5074\u7684\u7a7a\u683c\u6578\u5fc5\u9808\u76f8\u540c; \u4f46\u7576\u7121 slice \u53c3\u6578\u6642\uff0c\u5169\u5074\u7684\u7a7a\u683c\u53ef\u4ee5\u90fd\u7701\u7565\uff0c\u5982\uff1a<br \/>\n# \u4ee5\u4e0b\u662f\u6b63\u78ba\u7684\u98a8\u683c\uff1a<br \/>\nham[1:9], ham[1:9:3], ham[:9:3], ham[1::3], ham[1:9:]<br \/>\nham[lower:upper], ham[lower:upper:], ham[lower::step]<br \/>\nham[lower+offset : upper+offset]<br \/>\nham[: upper_fn(x) : step_fn(x)], ham[:: step_fn(x)]<br \/>\nham[lower + offset : upper + offset]<br \/>\n# \u4ee5\u4e0b\u662f\u932f\u8aa4\u7684\u98a8\u683c\uff1a<br \/>\nham[lower + offset:upper + offset]<br \/>\nham[1: 9], ham[1 :9], ham[1:9 :3]<br \/>\nham[lower : : upper]<br \/>\nham[ : upper]<br \/>\n\u51fd\u6578\u8abf\u7528\u7684 () \u53ca\u7d22\u5f15\u7684 [] \u524d\u4e0d\u8981\u52a0\u7a7a\u683c\uff0c\u5982\uff1a<br \/>\n# \u6b63\u78ba\u98a8\u683c\uff1a<br \/>\nspam(1)<br \/>\ndct[&#8216;key&#8217;] = lst[index]<br \/>\n# \u932f\u8aa4\u98a8\u683c\uff1a<br \/>\nspam (1)<br \/>\ndct [&#8216;key&#8217;] = lst [index]<br \/>\n\u4e0d\u8981\u5728\u8ce6\u503c\u8a9e\u53e5\u4e2d\u52a0\u5165\u984d\u5916\u7684\u7a7a\u683c\u4f86\u5c0d\u9f4a\uff0c\u5982\uff1a<br \/>\n# \u6b63\u78ba\u7684\u98a8\u683c\uff1a<br \/>\nx = 1<br \/>\ny = 2<br \/>\nlong_variable = 3<br \/>\n# \u932f\u8aa4\u7684\u98a8\u683c:<br \/>\nx = 1<br \/>\ny = 2<br \/>\nlong_variable = 3<\/p>\n<h4>\u5176\u5b83\u63a8\u85a6\u98a8\u683c<\/h4>\n<p>\u4efb\u4f55\u884c\u7684\u884c\u5c3e\u90fd\u4e0d\u8981\u6709\u7a7a\u767d\u7b26\u3002<br \/>\n\u5728\u4e8c\u5143\u64cd\u4f5c\u7b26\u865f\u5169\u5074\u4e00\u822c\u90fd\u8981\u52a0\u4e00\u500b\u7a7a\u683c\uff0c\u4e00\u822c\u7684\u4e8c\u5143\u64cd\u4f5c\u7b26\u865f\u5982\uff1a<br \/>\n\u8ce6\u503c: =, +=, -=<br \/>\n\u6bd4\u8f03\uff1a==, &lt;, &gt;, !=, &lt;&gt;, &lt;=, &gt;=, in, not in, is, is not<br \/>\n\u5e03\u6797\u64cd\u4f5c\uff1a and, or, not<br \/>\n\u5728\u5206\u512a\u5148\u7d1a\u7684\u8868\u9054\u5f0f\u4e2d\uff0c\u5728\u6700\u4f4e\u512a\u5148\u7d1a\u7684\u64cd\u4f5c\u7b26\u5169\u5074\u52a0\u4e00\u500b\u7a7a\u683c\uff0c\u4f46\u81f3\u591a\u53ea\u80fd\u52a0\u4e00\u500b\u7a7a\u683c\uff0c\u5982\uff1a<br \/>\n# \u6b63\u78ba\u7684\u98a8\u683c\uff1a<br \/>\nx = x*2 &#8211; 1<br \/>\nhypot2 = x*x + y*y<br \/>\nc = (a+b) * (a-b)<br \/>\n# \u932f\u8aa4\u7684\u98a8\u683c\uff1a<br \/>\nx = x * 2 &#8211; 1<br \/>\nhypot2 = x * x + y * y<br \/>\nc = (a + b) * (a &#8211; b)<br \/>\n<strong>\u5728\u95dc\u9375\u5b57\u53c3\u6578\u548c\u9ed8\u8a8d\u53c3\u6578\u503c\u4e2d\u7684 = \u5169\u5074\u4e0d\u8981\u52a0\u7a7a\u683c<\/strong>\uff0c\u5982\uff1a<br \/>\n# \u6b63\u78ba\u7684\u98a8\u683c\uff1a<br \/>\ndef complex(real, imag=0.0):<br \/>\nreturn magic(r=real, i=imag)<br \/>\n\u932f\u8aa4\u7684\u98a8\u683c\uff1a<br \/>\ndef complex(real, imag = 0.0):<br \/>\nreturn magic(r = real, i = imag)<br \/>\n<strong>\u51fd\u6578\u8a3b\u89e3\u4e2d\u7684 : \u524d\u4e0d\u8981\u52a0\u7a7a\u683c\uff0c\u9019\u7b26\u5408 : \u7684\u5e38\u898f\u98a8\u683c\uff0c\u4f46\u662f -&gt; \u5169\u5074\u8981\u52a0\u7a7a\u683c<\/strong>\uff0c\u5982\uff1a<br \/>\n# \u6b63\u78ba\u7684\u98a8\u683c\uff1a<br \/>\ndef munge(input: AnyStr): &#8230;<br \/>\ndef munge() -&gt; AnyStr: &#8230;<br \/>\n# \u932f\u8aa4\u7684\u98a8\u683c\uff1a<br \/>\ndef munge(input:AnyStr): &#8230;<br \/>\ndef munge()-&gt;PosInt: &#8230;<br \/>\n<strong>\u53c3\u6578\u8a3b\u89e3\u4e2d\uff0c\u5982\u679c\u8a3b\u89e3\u7684\u53c3\u6578\u6709\u9ed8\u8a8d\u503c\uff0c\u6307\u5b9a\u9ed8\u8a8d\u503c\u7684 = \u5169\u5074\u8981\u52a0\u7a7a\u683c<\/strong>\uff0c\u5982\uff1a<br \/>\n# \u6b63\u78ba\u7684\u98a8\u683c\uff1a<br \/>\ndef munge(sep: AnyStr = None): &#8230;<br \/>\ndef munge(input: AnyStr, sep: AnyStr = None, limit=1000): &#8230;<br \/>\n# \u932f\u8aa4\u7684\u98a8\u683c\uff1a<br \/>\ndef munge(input: AnyStr=None): &#8230;<br \/>\ndef munge(input: AnyStr, limit = 1000): &#8230;<\/p>\n<p><strong>\u4e0d\u8981\u5c07\u591a\u689d\u8a9e\u53e5\u7d44\u5408\u5728\u4e00\u884c\u4e2d<\/strong>\uff0c\u5982\uff1a<br \/>\n# \u6b63\u78ba\u7684\u98a8\u683c\uff1a<br \/>\nif foo == &#8216;blah&#8217;:<br \/>\ndo_blah_thing()<br \/>\ndo_one()<br \/>\ndo_two()<br \/>\ndo_three()<br \/>\n# \u932f\u8aa4\u98a8\u683c\uff1a<br \/>\nif foo == &#8216;blah&#8217;: do_blah_thing()<br \/>\ndo_one(); do_two(); do_three()<\/p>\n<p># \u5982\u679c if\/for\/while \u5340\u584a\u5167\u7684\u7a0b\u5f0f\u78bc\u5f88\u5c11\uff0c\u7d44\u5408\u5728\u4e00\u884c\u6709\u6642\u9084\u662f\u53ef\u4ee5\u63a5\u53d7\u7684<br \/>\n# \u4f46\u662f\u4e0d\u63a8\u85a6\uff0c\u5982\uff1a<br \/>\nif foo == &#8216;blah&#8217;: do_blah_thing()<br \/>\nfor x in lst: total += x<br \/>\nwhile t &lt; 10: t = delay()<br \/>\n# \u4f46\u662f\u5728\u6709\u591a\u6bb5\u8a9e\u53e5\u6642\uff0c\u7d55\u5c0d\u4e0d\u80fd\u9019\u6a23\uff0c\u5982\uff1a<br \/>\nif foo == &#8216;blah&#8217;: do_blah_thing()<br \/>\nelse: do_non_blah_thing()<\/p>\n<p>try: something()<br \/>\nfinally: cleanup()<\/p>\n<p>do_one(); do_two(); do_three(long, argument,<br \/>\nlist, like, this)<\/p>\n<p>if foo == &#8216;blah&#8217;: one(); two(); three()<\/p>\n<h4><strong>\u8a3b\u89e3 (Comments)<\/strong><\/h4>\n<p>\u8a3b\u89e3\u5167\u5bb9\u5fc5\u9808\u8981\u548c\u7a0b\u5f0f\u78bc\u76f8\u95dc\uff01<br \/>\n\u8a3b\u89e3\u61c9\u8a72\u662f\u5b8c\u6574\u7684\u8a9e\u53e5\uff0c\u9996\u5b57\u6bcd\u4e00\u822c\u5927\u5beb(\u82f1\u6587)\uff0c\u4e00\u822c\u8981\u6709\u53e5\u865f\u3002<br \/>\n\u8a3b\u89e3\u5f88\u77ed\u6642\u53e5\u865f\u53ef\u4ee5\u7701\u7565\u3002<br \/>\n\u5340\u584a\u8a3b\u89e3\u4e00\u822c\u7531\u591a\u500b\u6bb5\u843d\u7d44\u6210\u3002\u7528\u82f1\u6587\u5beb\u8a3b\u89e3<\/p>\n<h4><strong>\u5340\u584a\u8a3b\u89e3 (Block Comments)<\/strong><\/h4>\n<p>\u6bcf\u884c\u7528 # \u53ca\u4e00\u500b\u7a7a\u683c\u958b\u59cb\uff0c\u5982 #<br \/>\n\u6bb5\u843d\u7528\u4e00\u500b\u53ea\u6709 # \u7684\u884c\u5206\u9694<\/p>\n<h4><strong>\u884c\u5167\u8a3b\u89e3 (Inline Comments)<\/strong><\/h4>\n<p>\u8a3b\u89e3\u8207\u8a9e\u53e5\u5167\u5bb9\u81f3\u5c11\u7528\u5169\u500b\u7a7a\u683c\u5206\u958b\uff0c\u8a3b\u89e3\u7528 # \u52a0\u4e00\u500b\u7a7a\u683c\u958b\u59cb<br \/>\n# \u4e0d\u8981\u50cf\u4e0b\u9762\u9019\u6a23\uff0c\u8a3b\u89e3\u5167\u5bb9\u6c92\u6709\u5fc5\u8981<br \/>\nx = x + 1 # Increment x<br \/>\n# \u4f46\u662f\u6709\u6642\uff0c\u5982\u4e0b\u9762\u7684\u8a3b\u89e3\u6703\u5f88\u6709\u7528<br \/>\nx = x + 1 # Compensate for border<\/p>\n<h4>\u6587\u4ef6\u5b57\u4e32 (Documentation Strings)<\/h4>\n<p>\u516c\u958b\u7684\u6a21\u7d44\u3001\u51fd\u6578\u3001\u985e\u53ca\u65b9\u6cd5\u90fd\u61c9\u8a72\u6709\u6587\u4ef6\u5b57\u4e32\uff0c\u800c\u975e\u516c\u958b\u7684\u65b9\u6cd5\u53ef\u4ee5\u7528\u8a3b\u89e3\u4f86\u4ee3\u66ff\uff0c\u4e14\u8a3b\u89e3\u653e\u7f6e\u5728 def \u884c\u4e4b\u5f8c\u3002<br \/>\n\u591a\u884c\u7684\u6587\u4ef6\u5b57\u4e32\uff0c\u7d50\u675f\u7b26\u865f\u8981\u81ea\u6210\u4e00\u884c\uff0c\u5982\uff1a<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n&quot;&quot;&quot;Return a foobang\r\n\r\nOptional plotz says to frobnicate the bizbaz first.\r\n&quot;&quot;&quot;\r\n<\/pre>\n<p>\u55ae\u884c\u7684\u6587\u4ef6\u5b57\u4e32\uff0c\u7d50\u675f\u7b26\u865f\u548c\u5167\u5bb9\u653e\u5728\u540c\u4e00\u884c<\/p>\n<h4><strong>\u547d\u540d (Naming Conventions)<\/strong><\/h4>\n<p>\u6c92\u6709\u63a8\u85a6\u7684\u98a8\u683c\uff0c\u4f46\u662f\u5225\u4eba\u8981\u80fd\u5f9e\u4f60\u7684\u7a0b\u5f0f\u78bc\u4e2d\u770b\u51fa\u4f60\u7528\u7684\u662f\u4ec0\u9ebd\u98a8\u683c\uff0c\u5e38\u7528\u7684\u98a8\u683c\u5982\u4e0b\uff1a<\/p>\n<ul>\n<li>b \u55ae\u500b\u5c0f\u5beb\u5b57\u6bcd<\/li>\n<li>B \u55ae\u500b\u5927\u5beb\u5b57\u6bcd<\/li>\n<li>lowercase<\/li>\n<li>lower_case_with_underscores<\/li>\n<li>UPPERCASE<\/li>\n<li>UPPER_CASE_WITH_UNDERSCORES<\/li>\n<li>CapitalizedWords, \u9019\u7a2e\u98a8\u683c\u4e2d\uff0c\u5c0d\u65bc\u7e2e\u5beb\u8a5e\u61c9\u5168\u90e8\u7528\u5927\u5beb\uff0c\u5982<\/li>\n<li>HTTPServerError \u6bd4 HttpServerError \u597d<\/li>\n<li>mixedCase<br \/>\nCapitalized_Words_With_Underscores\uff0c\u9019\u500b\u592a\u919c\uff0c\u4e0d\u8981\u7528\u9019\u7a2e\uff01<\/li>\n<li>st_mode\u3001st_mtime \u7b49\u524d\u7db4\uff0c\u4e00\u822c\u662f\u7cfb\u7d71\u63a5\u53e3\u8fd4\u56de\uff0c\u5982\u679c\u81ea\u5df1\u5beb\u7684\u7a0b\u5f0f\u78bc\u4e0d\u63a8\u85a6\u7528\u9019\u7a2e<\/li>\n<li>_single_leading_underscore : \u5f31 \u201c\u5167\u90e8\u4f7f\u7528\u201d \u6307\u793a\u5668\uff0c\u9019\u7a2e\u5c0d\u8c61\u7528 from M import * \u4e0d\u6703\u88ab\u5c0e\u5165<\/li>\n<li>single_trailing_underscore_ : \u53ef\u4ee5\u7528\u4f86\u548c Python \u95dc\u9375\u8a5e\u9032\u884c\u5340\u5206\uff0c\u5982 Tkinter.Toplevel(master, class_=&#8217;ClassName&#8217;)<\/li>\n<li>__double_leading_underscore : \u547d\u540d\u4e00\u500b\u985e\u5c6c\u6027\u6642\uff0c\u53ef\u4ee5\u9032\u884c\u547d\u540d\u77ef\u6b63\uff0c\u4f8b\u5982 class FooBar \u5167\u7684 __boo \u6703\u8b8a\u6210 _FooBar__boo<\/li>\n<li>double_leading_and_trailing_underscore : \u201cmagic\u201d \u5c0d\u8c61\uff0c\u4e0d\u8981\u81ea\u5df1\u767c\u660e\u9019\u7a2e\u5c0d\u8c61<\/li>\n<\/ul>\n<h4><strong>\u547d\u540d\u7fd2\u6163 (Prescriptive: Naming Conventions)<\/strong><\/h4>\n<ul>\n<li>\u4e0d\u7528\u55ae\u500b l, O, I \u7b49\u9019\u6a23\u7684\u55ae\u500b\u5b57\u7b26\u4f86\u547d\u540d\uff0c\u5b83\u5011\u8207\u6578\u5b571,0\u4e0d\u597d\u5340\u5206<\/li>\n<li>\u5957\u4ef6\u540d\u548c\u6a21\u7d44\u540d\uff1a\u5168\u90e8\u7528\u5c0f\u5beb\uff0c\u5fc5\u8981\u6642\u53ef\u7528 _\uff0c\u4f46\u4e0d\u63a8\u85a6\uff0cC\/C++ \u7684\u64f4\u5c55\u6a21\u7d44\uff0c\u5982\u679c\u5176\u5c0d\u61c9\u6709 Python \u7248\u672c\uff0c\u90a3\u9ebd C\/C++ \u64f4\u5c55\u6a21\u7d44\u540d\u524d\u52a0 _<\/li>\n<li>\u985e\u5225\u540d\uff1a\u7528 CapWords \u98a8\u683c<\/li>\n<li>\u7570\u5e38\u540d\uff1a\u7528 CapWords \u98a8\u683c\uff0c\u4e00\u822c\u61c9\u8a72\u6709 Error \u5f8c\u7db4<\/li>\n<li>\u5168\u57df\u8b8a\u6578\u540d\uff1a\u80fd\u7528 from M import * \u5c0e\u5165\u7684\u8b8a\u6578\u5168\u90e8\u653e\u5728 __all__ \u4e2d\uff0c\u6216\u8005\u5168\u57df\u8b8a\u6578\u7528 _ \u505a\u524d\u7db4<\/li>\n<li>\u51fd\u6578\u540d\uff1a\u61c9\u8a72\u7528\u5168\u90e8\u7528\u5c0f\u5beb\uff0c\u55ae\u8a5e\u9593\u53ef\u4ee5\u7528 _ \u5206\u9694\uff0c\u5982 my_func\uff0c\u4e0d\u63a8\u85a6\u7528 mixedCase \u98a8\u683c<\/li>\n<li>\u51fd\u6578\u548c\u65b9\u6cd5\u7684\u53c3\u6578\uff1a\u5be6\u4f8b\u65b9\u6cd5\u7684\u7b2c\u4e00\u500b\u53c3\u6578\u7528 self, \u985e\u5225\u65b9\u6cd5\u7684\u7b2c\u4e00\u500b\u53c3\u6578\u7528 cls\uff0c\u5982\u679c\u53c3\u6578\u8207\u95dc\u9375\u5b57\u885d\u7a81\uff0c\u5728\u53c3\u6578\u540d\u5f8c\u52a0 _ \u5f8c\u7db4\uff0c\u5982 class_<\/li>\n<li>\u5be6\u4f8b\u8b8a\u6578\u548c\u65b9\u6cd5\uff1a \u7528\u5c0f\u5beb\u5b57\u7b26\u548c _, \u975e\u516c\u958b\u7684\u5be6\u4f8b\u8b8a\u6578\u548c\u65b9\u6cd5\u7528\u4e00\u500b _ \u505a\u524d\u7db4; \u907f\u514d\u8207\u5b50\u985e\u5225\u4e2d\u7684\u540d\u5b57\u885d\u7a81\uff0c\u985e\u7684\u8b8a\u6578\u53ef\u7528\u5169\u500b _ \u4f5c\u524d\u7db4\uff0c\u4f8b\u5982 class FooBar \u5167\u7684 __boo \u6703\u8b8a\u6210\u53ea\u80fd\u901a\u904e FooBar._FooBar__boo \u8b80\u53d6<\/li>\n<li>\u5e38\u6578\uff1a\u5168\u90e8\u5927\u5beb\uff0c\u53ef\u7528 _ \u5206\u9694\uff0c\u5982 MAX_OVERFLOW\u3001TOTAL<\/li>\n<\/ul>\n<h3><strong>\u63a8\u85a6\u7684\u7a0b\u5f0f\u64b0\u5beb\u65b9\u5f0f (Programming Recommendations)<\/strong><\/h3>\n<p>\u5b57\u7b26\u4e32\u9023\u63a5\u4e0d\u8981\u7528 a += b \u6216\u8005 a = a + b, \u7528 &#8220;.join(), \u5f8c\u8005\u6027\u80fd\u66f4\u597d\u3002\u8ddf None \u7684\u6bd4\u8f03\u7528 is \u548c is not\uff0c\u4e0d\u8981\u7528 ==\uff0c\u5982\u679c\u4f60\u60f3\u5224\u65b7 if x is not None, \u4e0d\u8981\u7e2e\u5beb\u6210 if x \u4f7f\u7528 if foo is not None\uff0c\u800c\u4e0d\u662f if not foo is None\uff0c\u524d\u8005\u66f4\u52a0\u6613\u8b80<\/p>\n<p>\u5982\u679c\u8981\u5be6\u73fe\u5e8f\u5217\u6bd4\u8f03\u64cd\u4f5c\u7684\u8a71\uff0c\u61c9\u5c07 6 \u500b\u64cd\u4f5c\uff08__eq__ , __ne__ , __lt__ , __le__ , __gt__ , __ge__\uff09\u5168\u90e8\u5be6\u73fe\uff0c\u53ef\u4ee5\u501f\u52a9 functools.total_ordering() \u4fee\u98fe\u5668\u4f86\u6e1b\u5c11\u5de5\u4f5c\u91cf<\/p>\n<p>\u5c07\u51fd\u6578\u4fdd\u5b58\u5728\u4e00\u500b\u8b8a\u6578\u4e2d\u61c9\u8a72\u7528 def f(x): return 2*x\uff0c \u800c\u975e f = lambda x: 2*x\uff0c\u5f8c\u8005\u4e0d\u5229\u65bc\u8abf\u8a66<\/p>\n<p>\u81ea\u5b9a\u7fa9\u7684\u7570\u5e38\u985e\u61c9\u8a72\u7e7c\u627f\u81f3 Exception \u985e\uff0c\u800c\u975e BaseException \u985e\u3002Python 2 \u4e2d\u62cb\u51fa\u7570\u5e38\u7528 raise ValueError(&#8216;message&#8217;)\uff0c\u800c\u975e raise ValueRoor, &#8216;message&#8217;<\/p>\n<p>\u76e1\u91cf\u53ef\u4ee5\u7684\u6307\u660e\u7570\u5e38\u540d\uff0c\u5982\uff1a<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\ntry:\r\n    import platform_specific_module\r\nexcept ImportError:\r\n    platform_specific_module = None\r\n<\/pre>\n<p>\u907f\u514d\u4f7f\u7528\u7121\u7570\u5e38\u540d\u7684 except: \u8a9e\u53e5\uff0c\u5b83\u6703\u6355\u7372\u5168\u90e8\u7684\u7570\u5e38\uff08\u5982 Ctrl C\uff09\u3002<br \/>\n\u5c07\u7570\u5e38\u7d81\u5b9a\u5230\u540d\u5b57\u7684\u65b9\u6cd5\uff1a<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\ntry:\r\n    process_data()\r\nexcept Exception as exc:\r\n    raise DataProcessingFailedError(str(exc))\r\n<\/pre>\n<p>try: \u4e2d\u7684\u8a9e\u53e5\u8981\u76e1\u91cf\u6e1b\u5c11\uff0c\u5982\uff1a<br \/>\n# \u6b63\u78ba\u7684\u5beb\u6cd5\uff1a<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\ntry:\r\n    value = collection[key]\r\nexcept KeyError:\r\n    return key_not_found(key)\r\nelse:\r\n    return handle_value(value)\r\n<\/pre>\n<p># \u932f\u8aa4\u7684\u5beb\u6cd5<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\ntry:\r\n    # Too broad!\r\n    return handle_value(collection[key])\r\nexcept KeyError:\r\n    # Will also catch KeyError raised by handle_value()\r\n    return key_not_found(key)\r\n<\/pre>\n<p>\u5982\u679c\u8cc7\u6e90\u53ea\u9069\u7528\u65bc\u67d0\u500b\u4ee3\u78bc\u6bb5\u5167\uff0c\u4f7f\u7528 with \u6216 try\/finally \u4f86\u78ba\u4fdd\u80fd\u9032\u884c\u6e05\u7406\u5de5\u4f5c<br \/>\n\u4e0a\u4e0b\u6587\u7ba1\u7406\u5668\u61c9\u7528\u901a\u904e\u4e00\u500b\u55ae\u7368\u7684\u51fd\u6578\u6216\u65b9\u6cd5\u4f86\u547c\u53eb\uff0c\u5982\uff1a<br \/>\n# \u6b63\u78ba\u7684\u505a\u6cd5\uff1a<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nwith conn.begin_transaction():\r\n    do_stuff_in_transaction(conn)\r\n<\/pre>\n<p># \u932f\u8aa4\u7684\u505a\u6cd5\uff1a<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nwith conn:\r\n    do_stuff_in_transaction(conn)\r\n<\/pre>\n<p>return \u8a9e\u53e5\u61c9\u8a72\u4e00\u81f4\uff0c\u5982\uff1a<br \/>\n# \u6b63\u78ba\u7684\u505a\u6cd5\uff1a<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\ndef foo(x):\r\n    if x &amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;gt;= 0:\r\n        return math.sqrt(x)\r\n    else:\r\n        return None\r\n\r\ndef bar(x):\r\n    if x &amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;lt; 0:\r\n        return None\r\n    return math.sqrt(x)\r\n<\/pre>\n<p># \u932f\u8aa4\u7684\u505a\u6cd5\uff1a<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\ndef foo(x):\r\n    if x &amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;gt;= 0:\r\n        return math.sqrt(x)\r\n\r\ndef bar(x):\r\n    if x &amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;lt; 0:\r\n        return\r\n    return math.sqrt(x)\r\n<\/pre>\n<p><strong>\u4f7f\u7528\u5b57\u7b26\u4e32\u7684\u65b9\u6cd5\uff0c\u800c\u4e0d\u662f\u7528 string \u6a21\u7d44\u4e2d\u7684\u65b9\u6cd5<\/strong><br \/>\n\u4f7f\u7528 &#8220;.startswith() \u548c &#8220;.endswidth() \u800c\u4e0d\u7528 slicing \u4f86\u6aa2\u67e5\u524d\u7db4\u548c\u5f8c\u7db4\uff1a<br \/>\n# \u6b63\u78ba\uff1a<br \/>\nif foo.startswith(&#8216;bar&#8217;):<br \/>\n# \u932f\u8aa4\uff1a<br \/>\nif foo[:3] == &#8216;bar&#8217;:<br \/>\n<strong>\u5224\u65b7\u5c0d\u8c61\u7684\u985e\u578b\u7528 isinstance \u800c\u4e0d\u76f4\u63a5 type \u6bd4\u8f03\uff0c\u5982\uff1a<\/strong><br \/>\n# \u6b63\u78ba\uff1a<br \/>\nif isinstance(obj, int):<br \/>\n# \u932f\u8aa4:<br \/>\nif type(obj) is type(1):<br \/>\n<strong>\u5c0d\u5e8f\u5217\u662f\u5426\u7a7a\u7684\u5224\u65b7\u4e0d\u7528 len\uff0c\u5982\uff1a<\/strong><br \/>\n# \u6b63\u78ba\uff1a<br \/>\nif not seq:<br \/>\nif seq:<br \/>\n# \u932f\u8aa4\uff1a<br \/>\nif len(seq):<br \/>\nif not len(seq):<br \/>\n<strong>\u5e03\u6797\u503c\u7684\u6bd4\u8f03\uff1a<\/strong><br \/>\n# \u6b63\u78ba\uff1a<br \/>\nif greeting:<br \/>\n# \u4e0d\u8981\u9019\u6a23:<br \/>\nif greeting == True:<br \/>\n# \u9019\u6a23\u66f4\u4e0d\u884c\uff1a<br \/>\nif greeting is True:<\/p>\n<hr \/>\n<p>\u53c3\u8003\u8cc7\u6599\uff1a<\/p>\n<p><a href=\"https:\/\/www.python.org\/dev\/peps\/pep-0008\/\">PEP 8 &#8212; Style Guide for Python Code<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>PEP 8 \u4ecb\u7d39 PEP8\u00a0\u662f Python \u793e\u7fa4\u5171\u901a\u7684\u98a8\u683c\u6307\u5357\uff0c\u4e00\u958b\u59cb\u662f Python \u4e4b\u7236 Guido van Rossum \u81ea\u5df1\u7684\u64b0\u78bc\u98a8\u683c\uff0c\u6162\u6162\u5f8c\u4f86\u6f14\u8b8a\u81f3\u4eca\uff0c\u76ee\u7684\u5728\u65bc\u5e6b\u52a9\u958b\u767c\u8005\u5beb\u51fa\u53ef\u8b80\u6027\u9ad8\u4e14\u98a8\u683c\u4e00\u81f4\u7684\u7a0b\u5f0f\u3002\u8a31\u591a\u958b\u6e90\u8a08\u756b\uff0c\u4f8b\u5982\u00a0Django\u00a0\u3001\u00a0OpenStack\u7b49\u90fd\u662f\u4ee5 PEP8 \u70ba\u57fa\u790e\u518d\u52a0\u4e0a\u81ea\u5df1\u7684\u98a8\u683c\u5efa\u8b70\u3002 \u7a0b\u5f0f\u78bc\u7de8\u6392 (Code lay-out) \u9019\u908a\u5217\u51faPEP8\u88e1\u9762\u7684\u91cd\u9ede\uff0c\u6709\u8208\u8da3\u53ef\u4ee5\u76f4\u63a5\u770b\u5b98\u65b9\u539f\u6587\u7684\u6587\u4ef6\u6703\u66f4\u6e05\u695a\u4e00\u4e9b\u3002 \u7e2e\u6392 (Indentation) \u6bcf\u5c64\u7e2e\u6392\u4f7f\u7528 4 \u500b\u7a7a\u683c \u65b7\u884c\u98a8\u683c \u6b63\u78ba\uff1a # \u65b7\u884c\u9996\u5b57\u6bcd\u8207\u958b\u982d\u7684\u62ec\u865f\u5782\u76f4\u5c0d\u9f4a. # \u5782\u76f4\u7e2e\u6392\uff0c\u9996\u884c\u4e0d\u80fd\u6709\u53c3\u6578. # \u5782\u76f4\u7e2e\u6392\uff0c\u5f8c\u9762\u9084\u6709\u5176\u5b83\u4ee3\u78bc\u6642\uff0c\u9700\u8981\u6dfb\u52a0\u4e00\u5c64\u984d\u5916\u7684\u7e2e\u6392\u52a0\u4ee5\u5340\u5225\uff1a \u932f\u8aa4\uff1a # \u5782\u76f4\u7e2e\u6392\u65b9\u5f0f\u9996\u884c\u4e0d\u80fd\u6709\u5f15\u6578 # \u5782\u76f4\u7e2e\u6392\uff0c\u9996\u884c\u4e0d\u80fd\u6709\u53c3\u6578; \u5f8c\u9762\u9084\u6709\u5176\u5b83\u4ee3\u78bc\u90e8\u5206\u6642\uff0c\u65b7\u884c\u8981\u6dfb\u52a0\u4e00\u5c64\u7e2e\u9032\uff0c\u4f7f\u5176\u8207\u5176\u5b83\u4ee3\u78bc\u90e8\u5206\u80fd\u5340\u5225\u958b\u4f86 if \u689d\u4ef6\u65b7\u884c if ( \u525b\u597d\u6709 4 \u500b\u5b57\u7b26\uff0c\u76f8\u7576\u65bc\u4e00\u5c64\u7e2e\u6392\u3002 \u5c0d\u65bc if \u689d\u4ef6\u65b7\u884c\uff0c\u4ee5\u4e0b\u5e7e\u7a2e\u98a8\u683c\u90fd\u53ef\u4ee5\uff1a \u6c92\u6709\u984d\u5916\u7684\u7e2e\u6392 \u6dfb\u52a0\u8a3b\u91cb\u52a0\u4ee5\u5340\u5206 \u6dfb\u52a0\u984d\u5916\u7684\u7e2e\u6392\u52a0\u4ee5\u5340\u5206 \u591a\u884c\u7684\u62ec\u865f \u62ec\u865f\u7d50\u675f\u7b26\u8207\u6700\u5f8c\u884c\u7684\u9996\u5b57\u7b26\u5c0d\u9f4a\uff0c\u5982\uff1a \u62ec\u865f\u7d50\u675f\u7b26\u8207\u9996\u884c\u7684\u9996\u5b57\u7b26\u5c0d\u9f4a, \u5982\uff1a \u4e0a\u9762\u5169\u7a2e\u6392\u7248\u7684\u65b9\u5f0f\u90fd\u53ef\u4ee5 &hellip; <a href=\"https:\/\/cflin.com\/wordpress\/603\/pep8-python%e7%b7%a8%e7%a2%bc%e8%a6%8f%e7%af%84%e6%89%8b%e5%86%8a\" class=\"more-link\">\u95b1\u8b80\u5168\u6587 <span class=\"screen-reader-text\">PEP8 Python \u7de8\u78bc\u898f\u7bc4\u624b\u518a<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false},"categories":[2],"tags":[17,18],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v19.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>PEP8 Python \u7de8\u78bc\u898f\u7bc4\u624b\u518a - \u53f0\u5927\u7cfb\u7d71\u8a13\u7df4\u73ed\u8ab2\u7a0b\u7db2\u9801 (\u6797\u5947\u8ce6)<\/title>\n<meta name=\"description\" content=\"PEP8 \u662f Python \u793e\u7fa4\u5171\u901a\u7684\u98a8\u683c\u6307\u5357\uff0c\u4e00\u958b\u59cb\u662f Python \u4e4b\u7236 Guido van Rossum \u81ea\u5df1\u7684\u64b0\u78bc\u98a8\u683c\uff0c\u6162\u6162\u5f8c\u4f86\u6f14\u8b8a\u81f3\u4eca\uff0c\u76ee\u7684\u5728\u65bc\u5e6b\u52a9\u958b\u767c\u8005\u5beb\u51fa\u53ef\u8b80\u6027\u9ad8\u4e14\u98a8\u683c\u4e00\u81f4\u7684\u7a0b\u5f0f\u3002\u8a31\u591a\u958b\u6e90\u8a08\u756b\uff0c\u4f8b\u5982 Django \u3001 OpenStack\u7b49\u90fd\u662f\u4ee5 PEP8 \u70ba\u57fa\u790e\u518d\u52a0\u4e0a\u81ea\u5df1\u7684\u98a8\u683c\u5efa\u8b70\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:\/\/cflin.com\/wordpress\/603\/pep8-python\u7de8\u78bc\u898f\u7bc4\u624b\u518a\" \/>\n<meta property=\"og:locale\" content=\"zh_TW\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PEP8 Python \u7de8\u78bc\u898f\u7bc4\u624b\u518a - \u53f0\u5927\u7cfb\u7d71\u8a13\u7df4\u73ed\u8ab2\u7a0b\u7db2\u9801 (\u6797\u5947\u8ce6)\" \/>\n<meta property=\"og:description\" content=\"PEP8 \u662f Python \u793e\u7fa4\u5171\u901a\u7684\u98a8\u683c\u6307\u5357\uff0c\u4e00\u958b\u59cb\u662f Python \u4e4b\u7236 Guido van Rossum \u81ea\u5df1\u7684\u64b0\u78bc\u98a8\u683c\uff0c\u6162\u6162\u5f8c\u4f86\u6f14\u8b8a\u81f3\u4eca\uff0c\u76ee\u7684\u5728\u65bc\u5e6b\u52a9\u958b\u767c\u8005\u5beb\u51fa\u53ef\u8b80\u6027\u9ad8\u4e14\u98a8\u683c\u4e00\u81f4\u7684\u7a0b\u5f0f\u3002\u8a31\u591a\u958b\u6e90\u8a08\u756b\uff0c\u4f8b\u5982 Django \u3001 OpenStack\u7b49\u90fd\u662f\u4ee5 PEP8 \u70ba\u57fa\u790e\u518d\u52a0\u4e0a\u81ea\u5df1\u7684\u98a8\u683c\u5efa\u8b70\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cflin.com\/wordpress\/603\/pep8-python\u7de8\u78bc\u898f\u7bc4\u624b\u518a\" \/>\n<meta property=\"og:site_name\" content=\"\u53f0\u5927\u7cfb\u7d71\u8a13\u7df4\u73ed\u8ab2\u7a0b\u7db2\u9801 (\u6797\u5947\u8ce6)\" \/>\n<meta property=\"article:published_time\" content=\"2017-12-05T10:15:03+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-12-05T10:20:49+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Chifu\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/cflin.com\/wordpress\/#website\",\"url\":\"https:\/\/cflin.com\/wordpress\/\",\"name\":\"\u53f0\u5927\u7cfb\u7d71\u8a13\u7df4\u73ed\u8ab2\u7a0b\u7db2\u9801 (\u6797\u5947\u8ce6)\",\"description\":\"\u53f0\u5927\u7cfb\u7d71\u8a13\u7df4\u73ed python \u8ab2\u7a0b\u76f8\u95dc\u8cc7\u6599\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/cflin.com\/wordpress\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-TW\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cflin.com\/wordpress\/603\/pep8-python%e7%b7%a8%e7%a2%bc%e8%a6%8f%e7%af%84%e6%89%8b%e5%86%8a#webpage\",\"url\":\"https:\/\/cflin.com\/wordpress\/603\/pep8-python%e7%b7%a8%e7%a2%bc%e8%a6%8f%e7%af%84%e6%89%8b%e5%86%8a\",\"name\":\"PEP8 Python \u7de8\u78bc\u898f\u7bc4\u624b\u518a - \u53f0\u5927\u7cfb\u7d71\u8a13\u7df4\u73ed\u8ab2\u7a0b\u7db2\u9801 (\u6797\u5947\u8ce6)\",\"isPartOf\":{\"@id\":\"https:\/\/cflin.com\/wordpress\/#website\"},\"datePublished\":\"2017-12-05T10:15:03+00:00\",\"dateModified\":\"2017-12-05T10:20:49+00:00\",\"author\":{\"@id\":\"https:\/\/cflin.com\/wordpress\/#\/schema\/person\/fcc9937e50465bfaa039229ad12d89aa\"},\"description\":\"PEP8 \u662f Python \u793e\u7fa4\u5171\u901a\u7684\u98a8\u683c\u6307\u5357\uff0c\u4e00\u958b\u59cb\u662f Python \u4e4b\u7236 Guido van Rossum \u81ea\u5df1\u7684\u64b0\u78bc\u98a8\u683c\uff0c\u6162\u6162\u5f8c\u4f86\u6f14\u8b8a\u81f3\u4eca\uff0c\u76ee\u7684\u5728\u65bc\u5e6b\u52a9\u958b\u767c\u8005\u5beb\u51fa\u53ef\u8b80\u6027\u9ad8\u4e14\u98a8\u683c\u4e00\u81f4\u7684\u7a0b\u5f0f\u3002\u8a31\u591a\u958b\u6e90\u8a08\u756b\uff0c\u4f8b\u5982 Django \u3001 OpenStack\u7b49\u90fd\u662f\u4ee5 PEP8 \u70ba\u57fa\u790e\u518d\u52a0\u4e0a\u81ea\u5df1\u7684\u98a8\u683c\u5efa\u8b70\u3002\",\"breadcrumb\":{\"@id\":\"https:\/\/cflin.com\/wordpress\/603\/pep8-python%e7%b7%a8%e7%a2%bc%e8%a6%8f%e7%af%84%e6%89%8b%e5%86%8a#breadcrumb\"},\"inLanguage\":\"zh-TW\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cflin.com\/wordpress\/603\/pep8-python%e7%b7%a8%e7%a2%bc%e8%a6%8f%e7%af%84%e6%89%8b%e5%86%8a\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cflin.com\/wordpress\/603\/pep8-python%e7%b7%a8%e7%a2%bc%e8%a6%8f%e7%af%84%e6%89%8b%e5%86%8a#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9801\",\"item\":\"https:\/\/cflin.com\/wordpress\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PEP8 Python \u7de8\u78bc\u898f\u7bc4\u624b\u518a\"}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/cflin.com\/wordpress\/#\/schema\/person\/fcc9937e50465bfaa039229ad12d89aa\",\"name\":\"Chifu\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-TW\",\"@id\":\"https:\/\/cflin.com\/wordpress\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/83c3d40c89fb05d334f2a3eddcfb4ac7?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/83c3d40c89fb05d334f2a3eddcfb4ac7?s=96&d=mm&r=g\",\"caption\":\"Chifu\"},\"sameAs\":[\"http:\/\/cflin.com\"],\"url\":\"https:\/\/cflin.com\/wordpress\/author\/daky\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PEP8 Python \u7de8\u78bc\u898f\u7bc4\u624b\u518a - \u53f0\u5927\u7cfb\u7d71\u8a13\u7df4\u73ed\u8ab2\u7a0b\u7db2\u9801 (\u6797\u5947\u8ce6)","description":"PEP8 \u662f Python \u793e\u7fa4\u5171\u901a\u7684\u98a8\u683c\u6307\u5357\uff0c\u4e00\u958b\u59cb\u662f Python \u4e4b\u7236 Guido van Rossum \u81ea\u5df1\u7684\u64b0\u78bc\u98a8\u683c\uff0c\u6162\u6162\u5f8c\u4f86\u6f14\u8b8a\u81f3\u4eca\uff0c\u76ee\u7684\u5728\u65bc\u5e6b\u52a9\u958b\u767c\u8005\u5beb\u51fa\u53ef\u8b80\u6027\u9ad8\u4e14\u98a8\u683c\u4e00\u81f4\u7684\u7a0b\u5f0f\u3002\u8a31\u591a\u958b\u6e90\u8a08\u756b\uff0c\u4f8b\u5982 Django \u3001 OpenStack\u7b49\u90fd\u662f\u4ee5 PEP8 \u70ba\u57fa\u790e\u518d\u52a0\u4e0a\u81ea\u5df1\u7684\u98a8\u683c\u5efa\u8b70\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:\/\/cflin.com\/wordpress\/603\/pep8-python\u7de8\u78bc\u898f\u7bc4\u624b\u518a","og_locale":"zh_TW","og_type":"article","og_title":"PEP8 Python \u7de8\u78bc\u898f\u7bc4\u624b\u518a - \u53f0\u5927\u7cfb\u7d71\u8a13\u7df4\u73ed\u8ab2\u7a0b\u7db2\u9801 (\u6797\u5947\u8ce6)","og_description":"PEP8 \u662f Python \u793e\u7fa4\u5171\u901a\u7684\u98a8\u683c\u6307\u5357\uff0c\u4e00\u958b\u59cb\u662f Python \u4e4b\u7236 Guido van Rossum \u81ea\u5df1\u7684\u64b0\u78bc\u98a8\u683c\uff0c\u6162\u6162\u5f8c\u4f86\u6f14\u8b8a\u81f3\u4eca\uff0c\u76ee\u7684\u5728\u65bc\u5e6b\u52a9\u958b\u767c\u8005\u5beb\u51fa\u53ef\u8b80\u6027\u9ad8\u4e14\u98a8\u683c\u4e00\u81f4\u7684\u7a0b\u5f0f\u3002\u8a31\u591a\u958b\u6e90\u8a08\u756b\uff0c\u4f8b\u5982 Django \u3001 OpenStack\u7b49\u90fd\u662f\u4ee5 PEP8 \u70ba\u57fa\u790e\u518d\u52a0\u4e0a\u81ea\u5df1\u7684\u98a8\u683c\u5efa\u8b70\u3002","og_url":"https:\/\/cflin.com\/wordpress\/603\/pep8-python\u7de8\u78bc\u898f\u7bc4\u624b\u518a","og_site_name":"\u53f0\u5927\u7cfb\u7d71\u8a13\u7df4\u73ed\u8ab2\u7a0b\u7db2\u9801 (\u6797\u5947\u8ce6)","article_published_time":"2017-12-05T10:15:03+00:00","article_modified_time":"2017-12-05T10:20:49+00:00","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Chifu","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebSite","@id":"https:\/\/cflin.com\/wordpress\/#website","url":"https:\/\/cflin.com\/wordpress\/","name":"\u53f0\u5927\u7cfb\u7d71\u8a13\u7df4\u73ed\u8ab2\u7a0b\u7db2\u9801 (\u6797\u5947\u8ce6)","description":"\u53f0\u5927\u7cfb\u7d71\u8a13\u7df4\u73ed python \u8ab2\u7a0b\u76f8\u95dc\u8cc7\u6599","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cflin.com\/wordpress\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-TW"},{"@type":"WebPage","@id":"https:\/\/cflin.com\/wordpress\/603\/pep8-python%e7%b7%a8%e7%a2%bc%e8%a6%8f%e7%af%84%e6%89%8b%e5%86%8a#webpage","url":"https:\/\/cflin.com\/wordpress\/603\/pep8-python%e7%b7%a8%e7%a2%bc%e8%a6%8f%e7%af%84%e6%89%8b%e5%86%8a","name":"PEP8 Python \u7de8\u78bc\u898f\u7bc4\u624b\u518a - \u53f0\u5927\u7cfb\u7d71\u8a13\u7df4\u73ed\u8ab2\u7a0b\u7db2\u9801 (\u6797\u5947\u8ce6)","isPartOf":{"@id":"https:\/\/cflin.com\/wordpress\/#website"},"datePublished":"2017-12-05T10:15:03+00:00","dateModified":"2017-12-05T10:20:49+00:00","author":{"@id":"https:\/\/cflin.com\/wordpress\/#\/schema\/person\/fcc9937e50465bfaa039229ad12d89aa"},"description":"PEP8 \u662f Python \u793e\u7fa4\u5171\u901a\u7684\u98a8\u683c\u6307\u5357\uff0c\u4e00\u958b\u59cb\u662f Python \u4e4b\u7236 Guido van Rossum \u81ea\u5df1\u7684\u64b0\u78bc\u98a8\u683c\uff0c\u6162\u6162\u5f8c\u4f86\u6f14\u8b8a\u81f3\u4eca\uff0c\u76ee\u7684\u5728\u65bc\u5e6b\u52a9\u958b\u767c\u8005\u5beb\u51fa\u53ef\u8b80\u6027\u9ad8\u4e14\u98a8\u683c\u4e00\u81f4\u7684\u7a0b\u5f0f\u3002\u8a31\u591a\u958b\u6e90\u8a08\u756b\uff0c\u4f8b\u5982 Django \u3001 OpenStack\u7b49\u90fd\u662f\u4ee5 PEP8 \u70ba\u57fa\u790e\u518d\u52a0\u4e0a\u81ea\u5df1\u7684\u98a8\u683c\u5efa\u8b70\u3002","breadcrumb":{"@id":"https:\/\/cflin.com\/wordpress\/603\/pep8-python%e7%b7%a8%e7%a2%bc%e8%a6%8f%e7%af%84%e6%89%8b%e5%86%8a#breadcrumb"},"inLanguage":"zh-TW","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cflin.com\/wordpress\/603\/pep8-python%e7%b7%a8%e7%a2%bc%e8%a6%8f%e7%af%84%e6%89%8b%e5%86%8a"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/cflin.com\/wordpress\/603\/pep8-python%e7%b7%a8%e7%a2%bc%e8%a6%8f%e7%af%84%e6%89%8b%e5%86%8a#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9801","item":"https:\/\/cflin.com\/wordpress"},{"@type":"ListItem","position":2,"name":"PEP8 Python \u7de8\u78bc\u898f\u7bc4\u624b\u518a"}]},{"@type":"Person","@id":"https:\/\/cflin.com\/wordpress\/#\/schema\/person\/fcc9937e50465bfaa039229ad12d89aa","name":"Chifu","image":{"@type":"ImageObject","inLanguage":"zh-TW","@id":"https:\/\/cflin.com\/wordpress\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/83c3d40c89fb05d334f2a3eddcfb4ac7?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/83c3d40c89fb05d334f2a3eddcfb4ac7?s=96&d=mm&r=g","caption":"Chifu"},"sameAs":["http:\/\/cflin.com"],"url":"https:\/\/cflin.com\/wordpress\/author\/daky"}]}},"_links":{"self":[{"href":"https:\/\/cflin.com\/wordpress\/wp-json\/wp\/v2\/posts\/603"}],"collection":[{"href":"https:\/\/cflin.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cflin.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cflin.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cflin.com\/wordpress\/wp-json\/wp\/v2\/comments?post=603"}],"version-history":[{"count":5,"href":"https:\/\/cflin.com\/wordpress\/wp-json\/wp\/v2\/posts\/603\/revisions"}],"predecessor-version":[{"id":608,"href":"https:\/\/cflin.com\/wordpress\/wp-json\/wp\/v2\/posts\/603\/revisions\/608"}],"wp:attachment":[{"href":"https:\/\/cflin.com\/wordpress\/wp-json\/wp\/v2\/media?parent=603"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cflin.com\/wordpress\/wp-json\/wp\/v2\/categories?post=603"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cflin.com\/wordpress\/wp-json\/wp\/v2\/tags?post=603"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}