{"id":543,"date":"2023-10-21T19:44:16","date_gmt":"2023-10-21T11:44:16","guid":{"rendered":"https:\/\/wp.minicoda.com\/?p=543"},"modified":"2023-10-21T19:44:16","modified_gmt":"2023-10-21T11:44:16","slug":"python","status":"publish","type":"post","link":"https:\/\/wp.minicoda.com\/index.php\/python\/","title":{"rendered":"Python"},"content":{"rendered":"\n<p>  \u4f5c\u4e3a\u4e00\u95e8\u811a\u672c\u8bed\u8a00\uff0c\u5728\u4eba\u5de5\u667a\u80fd\u9886\u57df\u7528\u8d77\u6765\u65b9\u4fbf\u7075\u6d3b\uff0c\u8bed\u6cd5\u7b80\u6d01\u81ea\u7531\u662f\u5f88\u5927\u539f\u56e0\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u67e5\u770b\u5b57\u8282\u7801<\/h2>\n\n\n\n<p>  \u5982\u4e0b\u793a\u4f8b\u7528dis\u5e93\u67e5\u770b\u5b57\u8282\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  >>> import dis\r\n  >>> dis.dis(lambda x, y, z: (x + y) * z)\r\n  1           0 LOAD_FAST                0 (x)\r\n              2 LOAD_FAST                1 (y)\r\n              4 BINARY_ADD\r\n              6 LOAD_FAST                2 (z)\r\n              8 BINARY_MULTIPLY\r\n             10 RETURN_VALUE<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">AST<\/h2>\n\n\n\n<p>  \u5982\u4e0b\u793a\u4f8b\u7528ast\u5e93\u67e5\u770b\u62bd\u8c61\u8bed\u6cd5\u6811\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>>>> import ast<br>>>> ast.dump(ast.parse(\"(3 - 1) * 2\"))<br>'Module(body=[Expr(value=BinOp(left=BinOp(left=Num(n=3), op=Sub(), right=Num(n=1)), op=Mult(), right=Num(n=2)))])'<\/p>\n<\/blockquote>\n<\/blockquote>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>\u4f5c\u4e3a\u4e00\u95e8\u811a\u672c\u8bed\u8a00\uff0c\u5728\u4eba\u5de5\u667a\u80fd\u9886\u57df\u7528\u8d77\u6765\u65b9\u4fbf\u7075\u6d3b\uff0c\u8bed\u6cd5\u7b80\u6d01\u81ea\u7531\u662f\u5f88\u5927\u539f\u56e0\u3002 \u67e5\u770b\u5b57\u8282\u7801 \u5982\u4e0b\u793a\u4f8b\u7528dis\u5e93\u67e5\u770b\u5b57\u8282\u7801\uff1a AST \u5982\u4e0b\u793a\u4f8b\u7528ast\u5e93\u67e5\u770b\u62bd\u8c61\u8bed\u6cd5\u6811\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[218,8],"tags":[219,9],"class_list":["post-543","post","type-post","status-publish","format-standard","hentry","category-python","category-8","tag-python","tag-9"],"views":88,"_links":{"self":[{"href":"https:\/\/wp.minicoda.com\/index.php\/wp-json\/wp\/v2\/posts\/543","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wp.minicoda.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wp.minicoda.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wp.minicoda.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wp.minicoda.com\/index.php\/wp-json\/wp\/v2\/comments?post=543"}],"version-history":[{"count":1,"href":"https:\/\/wp.minicoda.com\/index.php\/wp-json\/wp\/v2\/posts\/543\/revisions"}],"predecessor-version":[{"id":544,"href":"https:\/\/wp.minicoda.com\/index.php\/wp-json\/wp\/v2\/posts\/543\/revisions\/544"}],"wp:attachment":[{"href":"https:\/\/wp.minicoda.com\/index.php\/wp-json\/wp\/v2\/media?parent=543"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp.minicoda.com\/index.php\/wp-json\/wp\/v2\/categories?post=543"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp.minicoda.com\/index.php\/wp-json\/wp\/v2\/tags?post=543"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}