{"id":971979,"date":"2024-12-27T05:39:50","date_gmt":"2024-12-26T21:39:50","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/971979.html"},"modified":"2024-12-27T05:39:53","modified_gmt":"2024-12-26T21:39:53","slug":"python%e5%86%85%e5%ad%98%e6%b3%84%e6%bc%8f%e5%a6%82%e4%bd%95%e5%ae%9a%e4%bd%8d","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/971979.html","title":{"rendered":"python\u5185\u5b58\u6cc4\u6f0f\u5982\u4f55\u5b9a\u4f4d"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24194845\/b14f0bea-cd24-4c5a-b162-fd5301141c2a.webp\" alt=\"python\u5185\u5b58\u6cc4\u6f0f\u5982\u4f55\u5b9a\u4f4d\" \/><\/p>\n<p><p> <strong>Python\u5185\u5b58\u6cc4\u6f0f\u7684\u5b9a\u4f4d\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\uff1a\u4f7f\u7528\u5185\u5b58\u5206\u6790\u5de5\u5177\u3001\u68c0\u67e5\u4ee3\u7801\u4e2d\u7684\u5faa\u73af\u5f15\u7528\u3001\u4f18\u5316\u6570\u636e\u7ed3\u6784\u3001\u4f7f\u7528\u4e0a\u4e0b\u6587\u7ba1\u7406\u5668<\/strong>\u3002\u5176\u4e2d\uff0c\u4f7f\u7528\u5185\u5b58\u5206\u6790\u5de5\u5177\u662f\u6700\u5e38\u89c1\u4e14\u6709\u6548\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u5feb\u901f\u53d1\u73b0\u548c\u5b9a\u4f4d\u5185\u5b58\u6cc4\u6f0f\u7684\u95ee\u9898\u3002<\/p>\n<\/p>\n<p><p>\u4f7f\u7528\u5185\u5b58\u5206\u6790\u5de5\u5177\uff0c\u4f8b\u5982 <code>objgraph<\/code>\u3001<code>tracemalloc<\/code>\u3001<code>memory_profiler<\/code> \u7b49\uff0c\u53ef\u4ee5\u8ba9\u5f00\u53d1\u8005\u6df1\u5165\u4e86\u89e3\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\u3002\u4ee5 <code>tracemalloc<\/code> \u4e3a\u4f8b\uff0c\u5b83\u662f Python \u5185\u7f6e\u7684\u4e00\u4e2a\u5185\u5b58\u8ddf\u8e2a\u6a21\u5757\uff0c\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u8ddf\u8e2a\u5185\u5b58\u5206\u914d\u5e76\u8bc6\u522b\u5185\u5b58\u6cc4\u6f0f\u3002\u5f00\u53d1\u8005\u53ef\u4ee5\u901a\u8fc7\u542f\u7528 <code>tracemalloc<\/code>\uff0c\u5e76\u5728\u4ee3\u7801\u7684\u4e0d\u540c\u9636\u6bb5\u6293\u53d6\u5185\u5b58\u5feb\u7167\uff0c\u6bd4\u8f83\u8fd9\u4e9b\u5feb\u7167\u6765\u53d1\u73b0\u5185\u5b58\u6cc4\u6f0f\u7684\u6e90\u5934\u3002\u6b64\u5916\uff0c<code>tracemalloc<\/code> \u8fd8\u53ef\u4ee5\u63d0\u4f9b\u5185\u5b58\u5206\u914d\u7684\u8c03\u7528\u6808\u4fe1\u606f\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u66f4\u7cbe\u786e\u5730\u5b9a\u4f4d\u95ee\u9898\u6240\u5728\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u4f7f\u7528\u5185\u5b58\u5206\u6790\u5de5\u5177<\/p>\n<\/p>\n<p><p>\u5728\u5904\u7406\u5185\u5b58\u6cc4\u6f0f\u95ee\u9898\u65f6\uff0c\u5185\u5b58\u5206\u6790\u5de5\u5177\u662f\u5f00\u53d1\u8005\u7684\u597d\u5e2e\u624b\u3002\u8fd9\u4e9b\u5de5\u5177\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u8bc6\u522b\u548c\u5206\u6790\u4ee3\u7801\u4e2d\u6f5c\u5728\u7684\u5185\u5b58\u6cc4\u6f0f\u95ee\u9898\uff0c\u4ece\u800c\u66f4\u5feb\u901f\u5730\u5b9a\u4f4d\u95ee\u9898\u3002<\/p>\n<\/p>\n<ol>\n<li><strong><code>tracemalloc<\/code><\/strong><\/li>\n<\/ol>\n<p><p><code>tracemalloc<\/code> \u662f Python \u6807\u51c6\u5e93\u4e2d\u63d0\u4f9b\u7684\u4e00\u4e2a\u6a21\u5757\uff0c\u7528\u4e8e\u8ffd\u8e2a\u5185\u5b58\u5206\u914d\u3002\u901a\u8fc7\u4f7f\u7528 <code>tracemalloc<\/code>\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u83b7\u53d6\u7a0b\u5e8f\u5728\u4e0d\u540c\u65f6\u95f4\u70b9\u7684\u5185\u5b58\u4f7f\u7528\u5feb\u7167\uff0c\u5e76\u6bd4\u8f83\u8fd9\u4e9b\u5feb\u7167\u6765\u8bc6\u522b\u5185\u5b58\u6cc4\u6f0f\u3002<\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u4f60\u9700\u8981\u5728\u4ee3\u7801\u4e2d\u542f\u7528 <code>tracemalloc<\/code>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import tracemalloc<\/p>\n<p>tracemalloc.start()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\uff0c\u4f60\u53ef\u4ee5\u5728\u7a0b\u5e8f\u8fd0\u884c\u7684\u4e0d\u540c\u9636\u6bb5\u83b7\u53d6\u5185\u5b58\u5feb\u7167\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">snapshot1 = tracemalloc.take_snapshot()<\/p>\n<h2><strong>\u8fd0\u884c\u4e00\u4e9b\u53ef\u80fd\u5bfc\u81f4\u5185\u5b58\u6cc4\u6f0f\u7684\u4ee3\u7801<\/strong><\/h2>\n<p>snapshot2 = tracemalloc.take_snapshot()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u6bd4\u8f83\u4e24\u4e2a\u5feb\u7167\uff0c\u4f60\u53ef\u4ee5\u53d1\u73b0\u5185\u5b58\u5206\u914d\u7684\u53d8\u5316\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">top_stats = snapshot2.compare_to(snapshot1, &#39;lineno&#39;)<\/p>\n<p>print(&quot;[ Top differences ]&quot;)<\/p>\n<p>for stat in top_stats[:10]:<\/p>\n<p>    print(stat)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong><code>objgraph<\/code><\/strong><\/li>\n<\/ol>\n<p><p><code>objgraph<\/code> \u662f\u4e00\u4e2a\u53ef\u4ee5\u7528\u6765\u5206\u6790\u5bf9\u8c61\u5f15\u7528\u5173\u7cfb\u7684\u5e93\u3002\u5b83\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u53d1\u73b0\u5bf9\u8c61\u4e4b\u95f4\u7684\u5f15\u7528\u5faa\u73af\uff0c\u4ece\u800c\u8bc6\u522b\u5185\u5b58\u6cc4\u6f0f\u95ee\u9898\u3002<\/p>\n<\/p>\n<p><p>\u5b89\u88c5 <code>objgraph<\/code>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install objgraph<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4f7f\u7528 <code>objgraph<\/code> \u751f\u6210\u5bf9\u8c61\u5f15\u7528\u56fe\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import objgraph<\/p>\n<h2><strong>\u67e5\u770b\u5f53\u524d\u6700\u5e38\u89c1\u7684\u5bf9\u8c61\u7c7b\u578b<\/strong><\/h2>\n<p>objgraph.show_most_common_types()<\/p>\n<h2><strong>\u6253\u5370\u67d0\u4e2a\u7279\u5b9a\u5bf9\u8c61\u7684\u5f15\u7528\u94fe<\/strong><\/h2>\n<p>objgraph.show_backrefs([your_object], max_depth=3)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"3\">\n<li><strong><code>memory_profiler<\/code><\/strong><\/li>\n<\/ol>\n<p><p><code>memory_profiler<\/code> \u662f\u4e00\u4e2a\u53ef\u4ee5\u5e2e\u52a9\u76d1\u63a7 Python \u7a0b\u5e8f\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\u7684\u5e93\u3002\u901a\u8fc7\u4f7f\u7528 <code>memory_profiler<\/code>\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u66f4\u76f4\u89c2\u5730\u770b\u5230\u51fd\u6570\u5728\u6267\u884c\u8fc7\u7a0b\u4e2d\u7684\u5185\u5b58\u53d8\u5316\u3002<\/p>\n<\/p>\n<p><p>\u5b89\u88c5 <code>memory_profiler<\/code>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install memory_profiler<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4f7f\u7528 <code>memory_profiler<\/code> \u8fdb\u884c\u5185\u5b58\u5206\u6790\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from memory_profiler import profile<\/p>\n<p>@profile<\/p>\n<p>def my_function():<\/p>\n<p>    # \u4f60\u7684\u4ee3\u7801<\/p>\n<p>my_function()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e8c\u3001\u68c0\u67e5\u4ee3\u7801\u4e2d\u7684\u5faa\u73af\u5f15\u7528<\/p>\n<\/p>\n<p><p>\u5faa\u73af\u5f15\u7528\u662f Python \u4e2d\u5185\u5b58\u6cc4\u6f0f\u7684\u4e00\u4e2a\u5e38\u89c1\u539f\u56e0\u3002\u7531\u4e8e Python \u4f7f\u7528\u5f15\u7528\u8ba1\u6570\u6765\u7ba1\u7406\u5185\u5b58\uff0c\u5982\u679c\u4e24\u4e2a\u5bf9\u8c61\u4e92\u76f8\u5f15\u7528\uff0c\u5b83\u4eec\u7684\u5f15\u7528\u8ba1\u6570\u6c38\u8fdc\u4e0d\u4f1a\u964d\u5230\u96f6\uff0c\u4ece\u800c\u5bfc\u81f4\u5185\u5b58\u65e0\u6cd5\u91ca\u653e\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u8bc6\u522b\u5faa\u73af\u5f15\u7528<\/strong><\/li>\n<\/ol>\n<p><p>\u8bc6\u522b\u5faa\u73af\u5f15\u7528\u53ef\u4ee5\u901a\u8fc7<a href=\"https:\/\/docs.pingcode.com\/code-review\" target=\"_blank\">\u4ee3\u7801\u5ba1\u67e5<\/a>\u6216\u4f7f\u7528\u5de5\u5177\u6765\u5b9e\u73b0\u3002\u4f8b\u5982\uff0c<code>gc<\/code> \u6a21\u5757\u53ef\u4ee5\u5e2e\u52a9\u4f60\u8bc6\u522b\u5faa\u73af\u5f15\u7528\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import gc<\/p>\n<h2><strong>\u68c0\u67e5\u5f53\u524d\u7684\u5faa\u73af\u5f15\u7528<\/strong><\/h2>\n<p>gc.collect()<\/p>\n<p>print(gc.garbage)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u89e3\u51b3\u5faa\u73af\u5f15\u7528<\/strong><\/li>\n<\/ol>\n<p><p>\u89e3\u51b3\u5faa\u73af\u5f15\u7528\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u4f7f\u7528\u5f31\u5f15\u7528\uff1aPython \u63d0\u4f9b\u4e86 <code>weakref<\/code> \u6a21\u5757\uff0c\u53ef\u4ee5\u521b\u5efa\u5f31\u5f15\u7528\uff0c\u4e0d\u4f1a\u589e\u52a0\u5f15\u7528\u8ba1\u6570\u3002<\/li>\n<\/ul>\n<p><pre><code class=\"language-python\">import weakref<\/p>\n<p>class MyClass:<\/p>\n<p>    pass<\/p>\n<p>obj = MyClass()<\/p>\n<p>weak_obj = weakref.ref(obj)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ul>\n<li>\u4f7f\u7528\u4e0a\u4e0b\u6587\u7ba1\u7406\u5668\uff1a\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u4e0a\u4e0b\u6587\u7ba1\u7406\u5668\u53ef\u4ee5\u5e2e\u52a9\u4f60\u66f4\u597d\u5730\u7ba1\u7406\u8d44\u6e90\u7684\u5206\u914d\u548c\u91ca\u653e\uff0c\u4ece\u800c\u907f\u514d\u5faa\u73af\u5f15\u7528\u3002<\/li>\n<\/ul>\n<p><p>\u4e09\u3001\u4f18\u5316\u6570\u636e\u7ed3\u6784<\/p>\n<\/p>\n<p><p>\u9009\u62e9\u5408\u9002\u7684\u6570\u636e\u7ed3\u6784\u5bf9\u4e8e\u5185\u5b58\u7ba1\u7406\u975e\u5e38\u91cd\u8981\u3002\u5728\u7f16\u5199 Python \u7a0b\u5e8f\u65f6\uff0c\u5408\u7406\u9009\u62e9\u6570\u636e\u7ed3\u6784\u53ef\u4ee5\u6709\u6548\u51cf\u5c11\u5185\u5b58\u4f7f\u7528\u5e76\u907f\u514d\u5185\u5b58\u6cc4\u6f0f\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u4f7f\u7528\u751f\u6210\u5668<\/strong><\/li>\n<\/ol>\n<p><p>\u751f\u6210\u5668\u662f\u4e00\u79cd\u7279\u6b8a\u7684\u8fed\u4ee3\u5668\uff0c\u53ef\u4ee5\u5728\u8fed\u4ee3\u7684\u8fc7\u7a0b\u4e2d\u9010\u4e2a\u4ea7\u751f\u5143\u7d20\uff0c\u800c\u4e0d\u662f\u4e00\u6b21\u6027\u5c06\u6240\u6709\u5143\u7d20\u52a0\u8f7d\u5230\u5185\u5b58\u4e2d\u3002\u4f7f\u7528\u751f\u6210\u5668\u53ef\u4ee5\u663e\u8457\u51cf\u5c11\u5185\u5b58\u4f7f\u7528\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def my_generator():<\/p>\n<p>    for i in range(1000000):<\/p>\n<p>        yield i<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u4f7f\u7528\u9002\u5f53\u7684\u6570\u636e\u7ed3\u6784<\/strong><\/li>\n<\/ol>\n<p><p>\u6839\u636e\u6570\u636e\u7684\u4f7f\u7528\u573a\u666f\uff0c\u9009\u62e9\u9002\u5f53\u7684\u6570\u636e\u7ed3\u6784\u3002\u4f8b\u5982\uff0c\u4f7f\u7528 <code>set<\/code> \u4ee3\u66ff <code>list<\/code> \u6765\u5b58\u50a8\u552f\u4e00\u5143\u7d20\uff0c\u4f7f\u7528 <code>deque<\/code> \u6765\u66ff\u4ee3 <code>list<\/code> \u5b9e\u73b0\u961f\u5217\u64cd\u4f5c\u7b49\u3002<\/p>\n<\/p>\n<p><p>\u56db\u3001\u4f7f\u7528\u4e0a\u4e0b\u6587\u7ba1\u7406\u5668<\/p>\n<\/p>\n<p><p>\u4e0a\u4e0b\u6587\u7ba1\u7406\u5668\u662f\u4e00\u79cd\u7528\u4e8e\u7b80\u5316<a href=\"https:\/\/docs.pingcode.com\/blog\/project-management\/58557.html\" target=\"_blank\">\u8d44\u6e90\u7ba1\u7406<\/a>\u7684\u5de5\u5177\uff0c\u53ef\u4ee5\u81ea\u52a8\u7ba1\u7406\u8d44\u6e90\u7684\u5206\u914d\u548c\u91ca\u653e\uff0c\u907f\u514d\u624b\u52a8\u91ca\u653e\u8d44\u6e90\u5bfc\u81f4\u7684\u5185\u5b58\u6cc4\u6f0f\u95ee\u9898\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u4f7f\u7528 <code>with<\/code> \u8bed\u53e5<\/strong><\/li>\n<\/ol>\n<p><p>\u4f7f\u7528 <code>with<\/code> \u8bed\u53e5\u53ef\u4ee5\u786e\u4fdd\u5728\u4ee3\u7801\u5757\u6267\u884c\u5b8c\u6bd5\u540e\u81ea\u52a8\u91ca\u653e\u8d44\u6e90\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">with open(&#39;file.txt&#39;, &#39;r&#39;) as file:<\/p>\n<p>    data = file.read()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u521b\u5efa\u81ea\u5b9a\u4e49\u4e0a\u4e0b\u6587\u7ba1\u7406\u5668<\/strong><\/li>\n<\/ol>\n<p><p>\u5982\u679c\u9700\u8981\u7ba1\u7406\u81ea\u5b9a\u4e49\u8d44\u6e90\uff0c\u53ef\u4ee5\u521b\u5efa\u81ea\u5b9a\u4e49\u7684\u4e0a\u4e0b\u6587\u7ba1\u7406\u5668\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">class MyResource:<\/p>\n<p>    def __enter__(self):<\/p>\n<p>        # \u521d\u59cb\u5316\u8d44\u6e90<\/p>\n<p>        return self<\/p>\n<p>    def __exit__(self, exc_type, exc_value, traceback):<\/p>\n<p>        # \u91ca\u653e\u8d44\u6e90<\/p>\n<p>        pass<\/p>\n<p>with MyResource() as resource:<\/p>\n<p>    # \u4f7f\u7528\u8d44\u6e90<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u65b9\u6cd5\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u66f4\u6709\u6548\u5730\u5b9a\u4f4d\u548c\u89e3\u51b3 Python \u7a0b\u5e8f\u4e2d\u7684\u5185\u5b58\u6cc4\u6f0f\u95ee\u9898\uff0c\u4ece\u800c\u63d0\u9ad8\u7a0b\u5e8f\u7684\u6027\u80fd\u548c\u7a33\u5b9a\u6027\u3002\u65e0\u8bba\u662f\u4f7f\u7528\u5185\u5b58\u5206\u6790\u5de5\u5177\u3001\u68c0\u67e5\u5faa\u73af\u5f15\u7528\u3001\u4f18\u5316\u6570\u636e\u7ed3\u6784\uff0c\u8fd8\u662f\u4f7f\u7528\u4e0a\u4e0b\u6587\u7ba1\u7406\u5668\uff0c\u90fd\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u66f4\u597d\u5730\u7ba1\u7406\u5185\u5b58\u8d44\u6e90\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u8bc6\u522bPython\u4e2d\u7684\u5185\u5b58\u6cc4\u6f0f\uff1f<\/strong><br \/>\u8bc6\u522bPython\u4e2d\u7684\u5185\u5b58\u6cc4\u6f0f\u901a\u5e38\u53ef\u4ee5\u901a\u8fc7\u76d1\u63a7\u7a0b\u5e8f\u7684\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\u6765\u5b9e\u73b0\u3002\u53ef\u4ee5\u4f7f\u7528\u5de5\u5177\u5982<code>objgraph<\/code>\u3001<code>memory_profiler<\/code>\u548c<code>tracemalloc<\/code>\u7b49\u6765\u5206\u6790\u5185\u5b58\u5206\u914d\u548c\u5bf9\u8c61\u5f15\u7528\u3002\u901a\u8fc7\u8fd9\u4e9b\u5de5\u5177\uff0c\u4f60\u53ef\u4ee5\u627e\u51fa\u54ea\u4e9b\u5bf9\u8c61\u6ca1\u6709\u88ab\u91ca\u653e\uff0c\u4ece\u800c\u786e\u5b9a\u6f5c\u5728\u7684\u5185\u5b58\u6cc4\u6f0f\u3002<\/p>\n<p><strong>\u5185\u5b58\u6cc4\u6f0f\u7684\u5e38\u89c1\u539f\u56e0\u662f\u4ec0\u4e48\uff1f<\/strong><br \/>\u5185\u5b58\u6cc4\u6f0f\u5728Python\u4e2d\u53ef\u80fd\u7531\u591a\u79cd\u56e0\u7d20\u5f15\u8d77\uff0c\u5305\u62ec\u5faa\u73af\u5f15\u7528\u3001\u5168\u5c40\u53d8\u91cf\u7684\u6301\u4e45\u6027\u3001\u957f\u65f6\u95f4\u5b58\u6d3b\u7684\u5bf9\u8c61\u548c\u4e0d\u5f53\u4f7f\u7528\u7f13\u5b58\u7b49\u3002\u4e86\u89e3\u8fd9\u4e9b\u539f\u56e0\u6709\u52a9\u4e8e\u5f00\u53d1\u8005\u5728\u7f16\u5199\u4ee3\u7801\u65f6\u907f\u514d\u5e38\u89c1\u7684\u9519\u8bef\uff0c\u4ece\u800c\u51cf\u5c11\u5185\u5b58\u6cc4\u6f0f\u7684\u98ce\u9669\u3002<\/p>\n<p><strong>\u5982\u4f55\u6709\u6548\u5730\u9884\u9632\u5185\u5b58\u6cc4\u6f0f\uff1f<\/strong><br \/>\u9884\u9632\u5185\u5b58\u6cc4\u6f0f\u7684\u7b56\u7565\u5305\u62ec\u4f7f\u7528\u4e0a\u4e0b\u6587\u7ba1\u7406\u5668\u6765\u786e\u4fdd\u8d44\u6e90\u7684\u6b63\u786e\u91ca\u653e\u3001\u5b9a\u671f\u68c0\u67e5\u548c\u6e05\u7406\u4e0d\u518d\u4f7f\u7528\u7684\u5bf9\u8c61\u3001\u907f\u514d\u4e0d\u5fc5\u8981\u7684\u5168\u5c40\u53d8\u91cf\uff0c\u4ee5\u53ca\u4f7f\u7528\u5f31\u5f15\u7528\u6765\u7ba1\u7406\u5927\u578b\u5bf9\u8c61\u7684\u751f\u547d\u5468\u671f\u3002\u5229\u7528\u8fd9\u4e9b\u65b9\u6cd5\u53ef\u4ee5\u663e\u8457\u964d\u4f4e\u5185\u5b58\u6cc4\u6f0f\u7684\u53d1\u751f\u6982\u7387\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python\u5185\u5b58\u6cc4\u6f0f\u7684\u5b9a\u4f4d\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\uff1a\u4f7f\u7528\u5185\u5b58\u5206\u6790\u5de5\u5177\u3001\u68c0\u67e5\u4ee3\u7801\u4e2d\u7684\u5faa\u73af\u5f15\u7528\u3001\u4f18\u5316\u6570\u636e\u7ed3\u6784\u3001\u4f7f\u7528\u4e0a\u4e0b [&hellip;]","protected":false},"author":3,"featured_media":971990,"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\/971979"}],"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=971979"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/971979\/revisions"}],"predecessor-version":[{"id":971992,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/971979\/revisions\/971992"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/971990"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=971979"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=971979"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=971979"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}