{"id":2209,"date":"2015-06-08T00:14:40","date_gmt":"2015-06-07T16:14:40","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=2209"},"modified":"2015-06-08T00:14:40","modified_gmt":"2015-06-07T16:14:40","slug":"readpython%e9%ab%98%e6%89%8b%e4%b9%8b%e8%b7%af","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/2209.html","title":{"rendered":"[read]Python\u9ad8\u624b\u4e4b\u8def"},"content":{"rendered":"<p>\u9996\u5148\u8bf4\u660e\uff0c\u6211\u8fd8\u53ea\u662f\u4e2aPython\u65b0\u624b\uff0c\u867d\u7136\u63a5\u89e6Python\u5df2\u7ecf\u5feb\u4e00\u5e74\u4e86\uff0c\u4f46\u611f\u89c9\u4e5f\u5c31\u662f\u4e2a\u7528Python\u5199\u811a\u672c\u7684\uff0c\u6ca1\u6709\u5199\u8fc7\u5b9e\u9645\u53ef\u7528\u7684Python\u5927\u9879\u76ee\uff0c\u6c34\u5e73\u582a\u5fe7\u554ao(\u256f\u25a1\u2570)o<\/p>\n<p>\u6240\u4ee5\uff0c\u60f3\u63d0\u9ad8\u63d0\u9ad8\uff0c\u4e00\u65b9\u9762\u662f\u8bfb\u76f8\u5173\u4e66\u7c4d\u7cfb\u7edf\u5b66\u4e60\u7406\u8bba\u77e5\u8bc6\uff0c\u7136\u540e\u627e\u4e2a\u673a\u4f1a\u505a\u4e2a\u5927\u70b9\u7684\u9879\u76ee\uff0c\u4e5f\u8bb8\u6211\u7684Python\u6c34\u5e73\u5c31\u53ef\u4ee5\u63d0\u5347\u4e86\u5427\uff1f\u524d\u51e0\u5929\u5728China-Pub\u4e0a\u770b\u5230\u8fd9\u672c\u4e66\u7684\u63a8\u8350\uff0c\u4e8e\u662f\u7a0d\u5fae\u6298\u817e\u4e86\u4e00\u4e0b\uff08\u4e3b\u8981\u662f\u5728\u9009\u4e66\u4e0a\u9762\u6bd4\u8f83\u7ea0\u7ed3\u2014\u2014\u73b0\u5728\u4eac\u4e1c\u548c\u4e9a\u9a6c\u900a\u7684\u514d\u8fd0\u8d39\u95e8\u69db\u63d0\u5347\u4e86\u4e0d\u5c11\uff0c\u4e0d\u50cf\u4e4b\u524d\u4e70\u4e00\u672c\u4e66\u5c31\u53ef\u4ee5\u514d\u8d39\u914d\u9001\uff0c\u73b0\u5728\u5f97\u518d\u9009\u4e00\u4e24\u672c\u4e66\u4e00\u8d77\u4e0b\u5355\u624d\u884c\u2026\u2026\uff09\u7136\u540e\u65e9\u4e0a\u4e0b\u8ba2\u5355\uff0c\u665a\u4e0a\u5230\u8d27\uff1b\u521a\u5230\u8d27\u7684\u65f6\u5019\u89c9\u5f97\u4e66\u597d\u8584\u5440\uff0c\u6ca1\u6709\u901a\u5e38\u610f\u4e49\u4e0a\u8bb2Python\u7684\u90a3\u79cd\u5927\u90e8\u5934\u7684\u611f\u89c9\uff0c\u7136\u540e\u5c31\u89c9\u5f97\u4e66\u597d\u8d35\u554a\uff0c\u4e0d\u8fc7\u770b\u5b8c\u4e86\u4e4b\u540e\u5c31\u611f\u89c9\u2014\u2014\u597d\u4e66\u503c\u8fd9\u4e2a\u4ef7\uff01<\/p>\n<p>==<\/p>\n<p><strong>Python<\/strong><strong>\u9ad8\u624b\u4e4b\u8def<\/strong><\/p>\n<p><a href=\"https:\/\/julien.danjou.info\/books\/the-hacker-guide-to-python\" target=\"_blank\">https:\/\/julien.danjou.info\/books\/the-hacker-guide-to-python<\/a><\/p>\n<h6>\u7b2c1\u7ae0\u3000\u9879\u76ee\u5f00\u59cb<\/h6>\n<p>1.1 Python\u7248\u672c<\/p>\n<p>1.2 \u9879\u76ee\u7ed3\u6784<\/p>\n<p>1.3 \u7248\u672c\u7f16\u53f7<\/p>\n<p>1.4 \u7f16\u7801\u98ce\u683c\u4e0e\u81ea\u52a8\u68c0\u67e5<\/p>\n<h6>\u7b2c2\u7ae0\u3000\u6a21\u5757\u548c\u5e93<\/h6>\n<p>2.1 \u5bfc\u5165\u7cfb\u7edf<\/p>\n<p>2.2 \u6807\u51c6\u5e93<\/p>\n<p>2.3 \u5916\u90e8\u5e93<\/p>\n<p>2.4 \u6846\u67b6<\/p>\n<p>2.5 Doug Hellmann\u8bbf\u8c08<\/p>\n<p>2.6 \u7ba1\u7406API\u53d8\u5316<\/p>\n<p>2.7 Christophe de Vienne\u8bbf\u8c08<\/p>\n<h6>\u7b2c3\u7ae0\u3000\u6587\u6863<\/h6>\n<p>3.1 Sphinx\u548creST\u5165\u95e8<\/p>\n<p>3.2 Sphinx\u6a21\u5757<\/p>\n<p>3.3 \u6269\u5c55Sphinx<\/p>\n<h6>\u7b2c4\u7ae0\u3000\u5206\u53d1<\/h6>\n<p>4.1 \u7b80\u53f2<\/p>\n<p>4.2 \u4f7f\u7528pbr\u6253\u5305<\/p>\n<p>4.3 Wheel\u683c\u5f0f<\/p>\n<p>4.4 \u5305\u7684\u5b89\u88c5<\/p>\n<p>4.5 \u548c\u4e16\u754c\u5206\u4eab\u4f60\u7684\u6210\u679c<\/p>\n<p>4.6 Nick Coghlan\u8bbf\u8c08<\/p>\n<p>4.7 \u6269\u5c55\u70b9<\/p>\n<p>4.7.1 \u53ef\u89c6\u5316\u7684\u5165\u53e3\u70b9<\/p>\n<p>4.7.2 \u4f7f\u7528\u63a7\u5236\u53f0\u811a\u672c<\/p>\n<p>4.7.3 \u4f7f\u7528\u63d2\u4ef6\u548c\u9a71\u52a8\u7a0b\u5e8f<\/p>\n<h6>\u7b2c5\u7ae0\u3000\u865a\u62df\u73af\u5883<\/h6>\n<h6>\u7b2c6\u7ae0\u3000\u5355\u5143\u6d4b\u8bd5<\/h6>\n<p>6.1 \u57fa\u7840\u77e5\u8bc6<\/p>\n<p>6.2 fixture<\/p>\n<p>6.3 \u6a21\u62df\uff08mocking\uff09<\/p>\n<p>6.4 \u573a\u666f\u6d4b\u8bd5<\/p>\n<p>6.5 \u6d4b\u8bd5\u5e8f\u5217\u4e0e\u5e76\u884c<\/p>\n<p>6.6 \u6d4b\u8bd5\u8986\u76d6<\/p>\n<p>6.7 \u4f7f\u7528\u865a\u62df\u73af\u5883\u548ctox<\/p>\n<p>6.8 \u6d4b\u8bd5\u7b56\u7565<\/p>\n<p>6.9 Robert Collins\u8bbf\u8c08<\/p>\n<h6><span style=\"color: #ff0000;\"><strong>\u7b2c7\u7ae0\u3000\u65b9\u6cd5\u548c\u88c5\u9970\u5668<\/strong><\/span><\/h6>\n<p>7.1 \u521b\u5efa\u88c5\u9970\u5668<\/p>\n<p>7.2 Python\u4e2d\u65b9\u6cd5\u7684\u8fd0\u884c\u673a\u5236<\/p>\n<p>7.3 \u9759\u6001\u65b9\u6cd5<\/p>\n<p>7.4 \u7c7b\u65b9\u6cd5<\/p>\n<p>7.5 \u62bd\u8c61\u65b9\u6cd5<\/p>\n<p>7.6 \u6df7\u5408\u4f7f\u7528\u9759\u6001\u65b9\u6cd5\u3001\u7c7b\u65b9\u6cd5\u548c\u62bd\u8c61\u65b9\u6cd5<\/p>\n<p>7.7 \u5173\u4e8esuper\u7684\u771f\u76f8<\/p>\n<h6><span style=\"color: #ff0000;\"><strong>\u7b2c8\u7ae0\u3000\u51fd\u6570\u5f0f\u7f16\u7a0b<\/strong><\/span><\/h6>\n<p>8.1 \u751f\u6210\u5668<\/p>\n<p>8.2 \u5217\u8868\u89e3\u6790<\/p>\n<p>8.3 \u51fd\u6570\u5f0f\uff0c\u51fd\u6570\u7684\uff0c\u51fd\u6570\u5316<\/p>\n<h6>\u7b2c9\u7ae0\u3000\u62bd\u8c61\u8bed\u6cd5\u6811<\/h6>\n<p>9.1 Hy<\/p>\n<p>9.2 Paul Tagliamonte\u8bbf\u8c08<\/p>\n<h6><span style=\"color: #ff0000;\"><strong>\u7b2c10\u7ae0\u3000\u6027\u80fd\u4e0e\u4f18\u5316<\/strong><\/span><\/h6>\n<p>10.1 \u6570\u636e\u7ed3\u6784<\/p>\n<p>10.2 \u6027\u80fd\u5206\u6790<\/p>\n<p>10.3 \u6709\u5e8f\u5217\u8868\u548c\u4e8c\u5206\u67e5\u627e<\/p>\n<p>10.4 namedtuple\u548cslots<\/p>\n<p>10.5 memoization<\/p>\n<p>10.6 PyPy<\/p>\n<p>10.7 \u901a\u8fc7\u7f13\u51b2\u533a\u534f\u8bae\u5b9e\u73b0\u96f6\u590d\u5236<\/p>\n<p>10.8 Victor Stinner\u8bbf\u8c08<\/p>\n<h6>\u7b2c11\u7ae0\u3000\u6269\u5c55\u4e0e\u67b6\u6784<\/h6>\n<p>11.1 \u591a\u7ebf\u7a0b\u7b14\u8bb0<\/p>\n<p>11.2 \u591a\u8fdb\u7a0b\u4e0e\u591a\u7ebf\u7a0b<\/p>\n<p>11.3 \u5f02\u6b65\u548c\u4e8b\u4ef6\u9a71\u52a8\u67b6\u6784<\/p>\n<p>11.4 \u9762\u5411\u670d\u52a1\u67b6\u6784<\/p>\n<h6>\u7b2c12\u7ae0\u3000RDBMS\u548cORM<\/h6>\n<p>12.1 \u7528Flask\u548cPostgreSQL\u6d41\u5316\u6570\u636e<\/p>\n<p>12.2 Dimitri Fontaine\u8bbf\u8c08<\/p>\n<h6>\u7b2c13\u7ae0\u3000Python 3\u652f\u6301\u7b56\u7565<\/h6>\n<p>13.1 \u8bed\u8a00\u548c\u6807\u51c6\u5e93<\/p>\n<p>13.2 \u5916\u90e8\u5e93<\/p>\n<p>13.3 \u4f7f\u7528six<\/p>\n<h6>\u7b2c14\u7ae0\u3000\u5c11\u5373\u662f\u591a<\/h6>\n<p>14.1 \u5355\u5206\u53d1\u5668<\/p>\n<p>14.2 \u4e0a\u4e0b\u6587\u7ba1\u7406\u5668<\/p>\n<p>==<\/p>\n<p>\u5f88\u8584\u7684\u4e00\u672c\u4e66(202\u9875)\uff0c\u5206\u4e3a14\u7ae0\uff0c\u4e0d\u8fc7\u4e66\u4e2d\u7ed9\u51fa\u4e86\u6784\u5efa\u5e94\u7528\u7a0b\u5e8f\u65f6\u53ef\u53c2\u8003\u7684\u65b9\u6cd5\u548c\u5efa\u8bae\uff1a<\/p>\n<p>\u4ecePython\u7248\u672c\u7684\u9009\u53d6\u3001\u9879\u76ee\u76ee\u5f55\u7ed3\u6784\u7684\u8bbe\u7f6e\u4ee5\u53ca\u9879\u76ee\u7f16\u53f7\u7684\u89c4\u8303\u6027(pep-0440\/0426)\u5f00\u59cb\uff0c\u7f16\u7801\u98ce\u683c\u7684\u68c0\u67e5(PEP 8\u89c4\u8303\u4ee5\u53ca\u68c0\u67e5\u5de5\u5177flake8\/hacking)\uff0c\u6a21\u5757\u548c\u5e93\u7684\u8bf4\u660e(\u4efb\u4f55\u65f6\u5019\u60f3\u8981\u81ea\u5df1\u5199\u51fd\u6570\u5904\u7406\u4e00\u4e9b\u7b80\u5355\u7684\u5de5\u5177\u65f6\uff0c\u8bf7\u5148\u505c\u4e0b\u6765\u770b\u770b\u6807\u51c6\u5e93)(\u5916\u90e8\u5e93\u7684\u4f7f\u7528\u8981\u614e\u4e4b\u53c8\u614e)\uff0c\u4ee5\u53ca\u5728\u6b63\u89c4\u9879\u76ee\u4e2d\u6587\u6863\u7684\u91cd\u8981\u6027(Python\u4e2d\u6587\u6863\u683c\u5f0f\u7684\u4e8b\u5b9e\u6807\u51c6\u662freStructuredText\uff0c\u6216\u7b80\u79f0reST\uff1bSphinx\u662f\u5904\u7406\u8fd9\u4e00\u683c\u5f0f\u6700\u5e38\u7528\u7684\u5de5\u5177)\uff0c\u9488\u5bf9\u73b0\u9636\u6bb5Python\u5b58\u5728\u7684\u5404\u79cd\u5206\u53d1\u5de5\u5177\u4e5f\u6709\u4e86\u7b80\u660e\u627c\u8981\u7684\u4ecb\u7ecd(\u7b80\u800c\u8a00\u4e4b\uff0csetuptools\u662f\u76ee\u524d\u5206\u53d1\u5e93\u7684\u4e3b\u8981\u9009\u62e9\uff0c\u4f46\u5728\u672a\u6765\u8981\u5bf9distlib\u4fdd\u6301\u5173\u6ce8\uff1bpip freeze)\uff0c\u865a\u62df\u73af\u5883\u7684\u8bbe\u7f6e\uff0c\u7279\u522b\u5f3a\u8c03\u4e86\u5355\u5143\u6d4b\u8bd5\u7684\u91cd\u8981\u6027\uff1b\u7b2c7\u30018\u300110\u7ae0\u662f\u6211\u6700\u611f\u5174\u8da3\u7684\u7ae0\u8282\uff0c\u7b2c9\u7ae0(\u62bd\u8c61\u8bed\u6cd5\u6811\uff0cAST)\u5bf9\u73b0\u5728\u7684\u6211\u6765\u8bf4\u57fa\u672c\u4e0a\u5c31\u662f\u5929\u4e66\uff0c\u8349\u8349\u7ffb\u9605\u8fc7\uff1b\u7b2c11\u300112\u7ae0\u56e0\u4e3a\u7528\u7684\u5c11\u6240\u4ee5\u5173\u6ce8\u7684\u4e5f\u5c11\uff0c\u5e0c\u671b\u4ee5\u540e\u4f1a\u6709\u673a\u4f1a\u7528\u5230(GIL\uff1bmultiprocessing\uff1b\u5f02\u6b65\u548c\u4e8b\u4ef6\u9a71\u52a8\u67b6\u6784)\uff1b\u56e0\u4e3a\u73b0\u9636\u6bb5\u4e5f\u4e3b\u8981\u662f\u5728Python2.7\u4e0a\u8fdb\u884c\u7f16\u7a0b\uff0c\u6240\u4ee5\u7b2c13\u7ae0Python3\u652f\u6301\u7b56\u7565\u53ea\u662f\u5927\u6982\u4e86\u89e3\u4e86\u4e0b(\u63a8\u8350\u4f7f\u7528six\u6a21\u5757\uff0c\u800c\u4e0d\u662f2to3\/3to2\u8fd9\u6837\u7684\u5de5\u5177)\uff0c\u7b2c14\u7ae0\u7684\u201c\u5355\u5206\u53d1\u5668\u201d\u8fd8\u6ca1\u600e\u4e48\u770b\u5c31\u7ffb\u8fc7\u53bb\u4e86\uff0c\u201c\u4e0a\u4e0b\u6587\u7ba1\u7406\u5668\u201d\u4e4b\u524d\u6709\u8fc7\u4e86\u89e3\u5c31\u6ca1\u7ec6\u770b\uff0c\u4e0d\u8fc7\u6700\u540e\u90a3\u4e2a&#8217;\u901a\u8fc7\u4e00\u6761with\u8bed\u53e5\u540c\u65f6\u6253\u5f00\u4e24\u4e2a\u6587\u4ef6&#8217;\u90a3\u4e2atips\u8fd8\u662f\u6709\u70b9\u7528\u5904\u3002<\/p>\n<p>\u5176\u5b9e\uff0c\u672c\u4e66\u5bf9\u6211\u7684\u5438\u5f15\u529b\u9664\u4e86\u662f\u4ece\u4f5c\u8005\u7684\u5b9e\u6218\u7ecf\u9a8c\u51fa\u53d1\u4e3a\u8bfb\u8005\u63d0\u4f9b\u5b9e\u8df5\u5efa\u8bae\u548c\u5de5\u5177\u4e4b\u5916\uff0c\u6700\u5927\u7684\u6536\u83b7\u5c31\u662f\u2014\u2014\u4e13\u5bb6\u8bbf\u8c08\uff0c\u53c2\u4e0e\u8bbf\u8c08\u7684\u4e13\u5bb6\u57fa\u672c\u4e0a\u90fd\u662fPython\u5927\u725b\uff0c\u5206\u4eab\u4e86\u4ed6\u4eec\u5728\u8fdb\u884cmodule\u5f00\u53d1\u3001API\u8bbe\u8ba1\u3001PEP\u7f16\u5199\u65f6\u4e3b\u8981\u8003\u8651\u7684\u4e00\u4e9b\u95ee\u9898\uff0c\u771f\u7684\u53ef\u4ee5\u901a\u8fc7\u5176\u4e2d\u7684\u8bbf\u8c08\u4ece\u8fd9\u4e9b\u4e13\u5bb6\u90a3\u91cc\u83b7\u5f97\u610f\u89c1\u3001\u5efa\u8bae\u548c\u6280\u5de7\u3002<\/p>\n<p>\u6240\u4ee5\uff0c\u603b\u4f53\u6765\u8bf4\uff0c\u633a\u68d2\u7684\u4e00\u672c\u4e66\uff0c\u503c\u5f97\u8d2d\u4e70\u3002<\/p>\n<p>==<\/p>\n<pre class=\"lang:default decode:true \">with open(\"file1\", \"r\") as source, open(\"file2\", \"w\") as destination:\n    destination.write(source.read())<\/pre>\n<p>PEP(Python Enhancement Proposal\uff0cPython\u589e\u5f3a\u63d0\u6848)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9996\u5148\u8bf4\u660e\uff0c\u6211\u8fd8\u53ea\u662f\u4e2aPython\u65b0\u624b\uff0c\u867d\u7136\u63a5\u89e6Python\u5df2\u7ecf\u5feb\u4e00\u5e74\u4e86\uff0c\u4f46\u611f\u89c9\u4e5f\u5c31\u662f\u4e2a\u7528Python\u5199\u811a\u672c\u7684\uff0c [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,7,12],"tags":[8,320],"class_list":["post-2209","post","type-post","status-publish","format-standard","hentry","category-knowledgebase-2","category-programing","category-tools","tag-python","tag-reading"],"views":5478,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/2209","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=2209"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/2209\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=2209"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=2209"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=2209"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}