{"id":1360,"date":"2022-10-28T17:28:11","date_gmt":"2022-10-28T09:28:11","guid":{"rendered":"http:\/\/175.24.184.226\/?p=1360"},"modified":"2022-10-28T17:28:11","modified_gmt":"2022-10-28T09:28:11","slug":"python%e5%86%85%e5%ad%98%e6%b3%84%e6%bc%8f%e6%8e%a2%e8%ae%a8","status":"publish","type":"post","link":"\/?p=1360","title":{"rendered":"python\u5185\u5b58\u6cc4\u6f0f\u63a2\u8ba8"},"content":{"rendered":"<h3>\u6587\u7ae0\u76ee\u5f55<\/h3>\n<ul>\n<li>\n<p><a href=\"about:blank#_4\">\u524d\u8a00<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"about:blank#python_10\">\u4e00\u3001python\u5185\u5b58\u6cc4\u6f0f\u539f\u56e0<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"about:blank#_55\">\u4e8c\u3001\u5faa\u73af\u7834\u89e3<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"about:blank#requests_60\">\u4e09\u3001\u4f7f\u7528requests\u4e2d\u7684\u5185\u5b58\u6cc4\u6f0f\u95ee\u9898<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"about:blank#opencv_69\">\u56db\u3001opencv\u5185\u5b58\u6cc4\u6f0f\uff08\u672a\u89e3\u51b3\u8fc7\uff09<\/a><\/p>\n<\/li>\n<li>\n<ul>\n<li>*<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h1><a href=\"https:\/\/blog.csdn.net\/weixin_41023564\/article\/details\/115310004\"><\/a>\u524d\u8a00<\/h1>\n<p>python\u5728\u6b63\u5e38\u4f7f\u7528\u60c5\u51b5\u4e0b\uff0c\u4e0d\u4f1a\u51fa\u73b0\u5185\u5b58\u6cc4\u6f0f\u3002\u4f46\u662f\u9047\u5230request\u3001opencv\u6a21\u5757\u65f6\u5c31\u7ecf\u5e38\u88ab\u7206\u51fa\u5185\u5b58\u6cc4\u6f0f\u3002\u672c\u6587\u4e3b\u8981\u8bb2\u8ff0requests\u4e0b\u51fa\u73b0\u5185\u5b58\u6cc4\u6f0f\u89e3\u51b3\u529e\u6cd5\uff08PS\uff1aopencv\u8fd9\u79cd\u6a21\u5757\u8fd8\u6ca1\u6709\u4f7f\u7528\u8fc7\uff09\u3002<\/p>\n<hr \/>\n<h1><a href=\"https:\/\/blog.csdn.net\/weixin_41023564\/article\/details\/115310004\"><\/a>\u4e00\u3001python\u5185\u5b58\u6cc4\u6f0f\u539f\u56e0<\/h1>\n<p>\u8bb2\u5185\u5b58\u6cc4\u6f0f\u539f\u56e0\u4e0d\u5982\u4e86\u89e3\u4e00\u4e0bpython\u5185\u5b58\u7ba1\u7406\u673a\u5236\u5c31\u660e\u767d\u4e86\u3002\u7f51\u4e0a\u641c\u7d22\u5927\u6982\u5982\u4e0b\uff1a<\/p>\n<pre><code>1\uff0c\u5f15\u7528\u8ba1\u6570\n2\uff0c\u5783\u573e\u56de\u6536\n3\uff0c\u5185\u5b58\u6c60\n<\/code><\/pre>\n<p>\u4f8b\u5982\u4e00\u4e2a\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre><code>def func():\n    a= 10\nfunc()\nprint\uff08&#039;\u6267\u884c\u5230\u8fd9\u91ccfunc\u51fd\u6570\u4e2da\u53d8\u91cf\u7684\u5f15\u7528\u8ba1\u6570\u4e3a0\uff0ca\u6307\u5411\u7684\u5730\u5740\u4e3a\u5783\u573e\u5185\u5b58\uff0c\u5373\u53ef\u88abpython\u56de\u6536&#039;)\n<\/code><\/pre>\n<p>\u4ee5\u4e0b\u4ee3\u7801\u51fd\u6570\u5185\u53d8\u91cf\u4e0d\u80fd\u591f\u88ab\u91ca\u653e\uff1a<\/p>\n<pre><code>import sys\nclass A:\n    def __init__(self):\n        self.a = None\ndef func():\n    a1 = A()\n    a2 = A()\n    a3 = A()\n    print(&#039;a1\/a2\u5f15\u7528\u8ba1\u6570\u4e3a2&#039;)\n    print(&#039;a1:&#039;,sys.getrefcount(a1))\n    a1.a = a2\n    a2.a = a1\n    print(&#039;a1:&#039;,sys.getrefcount(a1))\n    a3.a = a1\n    print(&#039;a1:&#039;,sys.getrefcount(a1))\n    del a3# \u5220\u9664a3\u540c\u65f6\u51cf\u5c11a1\u7684\u5f15\u7528\u8ba1\u6570\n    print(&#039;a1:&#039;,sys.getrefcount(a1))\n\n    print(id(a2.a))\n    return\n    # \u8fd9\u4e2a\u6267\u884c\u4e4b\u540e\uff0ca3\u5f15\u7528\u8ba1\u6570\u6ee1\u8db3\u5185\u5b58\u91ca\u653e\u6761\u4ef6\n    # a1,a2 \u5f15\u7528\u8ba1\u6570\u4e0d\u6ee1\u8db3\u5185\u5b58\u91ca\u653e\u6761\u4ef6\nfunc()\n# \u6267\u884c\u5230\u6b64\uff0ca3\u88ab\u56de\u6536\uff08\u6216\u8005\u53ef\u56de\u6536\u72b6\u6001\uff09\uff0c\u800ca1,a2\u7528\u7531\u4e8e\u76f8\u4e92\u5f15\u7528\uff0c\u5728\u51fd\u6570func\u6267\u884c\u5b8c\u4e4b\u540e\n# \u800c\u4e0d\u80fd\u591f\u88ab\u56de\u6536\uff0c\u53d8\u6210\u4e0d\u53ef\u7ba1\u7406\u7684\u5783\u573e\u5185\u5b58\n<\/code><\/pre>\n<h1><a href=\"https:\/\/blog.csdn.net\/weixin_41023564\/article\/details\/115310004\"><\/a>\u4e8c\u3001\u5faa\u73af\u7834\u89e3<\/h1>\n<p>\u5728func\u9000\u51fa\u4e4b\u524d\u5bf9a1.a\u3001a2.a\u8d4b\u4e88\u4e00\u4e2aNone\u503c\u5373\u53ef\uff0c\u89e3\u9664\u5faa\u73af\u5f15\u7528\u5bfc\u81f4\u5783\u573e\u5185\u5b58\u4e0d\u80fd\u591f\u56de\u6536\u3002<\/p>\n<h1><a href=\"https:\/\/blog.csdn.net\/weixin_41023564\/article\/details\/115310004\"><\/a>\u4e09\u3001\u4f7f\u7528requests\u4e2d\u7684\u5185\u5b58\u6cc4\u6f0f\u95ee\u9898<\/h1>\n<p>requests\u7531\u4e8e\u4e0d\u65ad\u5faa\u73af\u6216\u8005\u4f7f\u7528\u591a\u7ebf\u7a0b\u8fc7\u7a0b\uff0c\u9012\u5f52\u8c03\u7528requests\uff0c\u5bfc\u81f4\u5185\u90e8\u5bf9\u8c61\u76f8\u4e92\u5f15\u7528\u800c\u5f97\u4e0d\u5230\u91ca\u653e\uff0c\u5bfc\u81f4\u5185\u5b58\u4f7f\u7528\u4e0d\u65ad\u7d2f\u79ef\u800c\u4e0d\u80fd\u591f\u91ca\u653e\u3002<\/p>\n<p><strong>\u89e3\u51b3\u529e\u6cd5\uff1a<\/strong>\u5728\u4f7f\u7528requests\u51fd\u6570\u5185\u90e8\uff0c\u8fdb\u884c\u6570\u636e\u5904\u7406\uff1a\u53ea\u4f7f\u7528\u8fd4\u56de\u5bf9\u8c61\u4e2d\u72b6\u6001\u5b57\u6bb5\u3001text\u51e0\u79cd\u5b57\u6bb5\uff0c\u4e0d\u8981\u628a\u8fd9\u4e2a\u8fd4\u56de\u5bf9\u8c61\u8fdb\u884c\u5f15\u7528\u3002<br \/>\n<strong>\u4e34\u65f6\u89e3\u51b3\u529e\u6cd5\uff1a<\/strong>\u4f7f\u7528\u591a\u8fdb\u7a0b\u8fdb\u884c\u5904\u7406\uff0c\u4f8b\u5982\u67091000\u4e2a\u5173\u952e\u8bcd\u8981\u67e5\u8be2\uff0c\u9700\u8981\u4e0d\u65ad\u9012\u5f52\u67e5\u8be2\u76f4\u5230\u6ee1\u8db3\u67d0\u4e2a\u6761\u4ef6\u9000\u51fa\uff0c\u8fd9\u75281000\u4e2a\u591a\u8fdb\u7a0b\u8fdb\u884c\u5904\u7406\uff0c\u6bcf\u6b21\u5904\u740610\u4e2a\u5173\u952e\u8bcd\u3002  <\/p>\n<h1><a href=\"https:\/\/blog.csdn.net\/weixin_41023564\/article\/details\/115310004\"><\/a>\u56db\u3001opencv\u5185\u5b58\u6cc4\u6f0f\uff08\u672a\u89e3\u51b3\u8fc7\uff09<\/h1>\n<p>\u672c\u6587\u8f6c\u81ea <a href=\"https:\/\/blog.csdn.net\/weixin_41023564\/article\/details\/115310004\">https:\/\/blog.csdn.net\/weixin_41023564\/article\/details\/115310004<\/a>\uff0c\u5982\u6709\u4fb5\u6743\uff0c\u8bf7\u8054\u7cfb\u5220\u9664\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u76ee\u5f55 \u524d\u8a00 \u4e00\u3001python\u5185\u5b58\u6cc4\u6f0f\u539f\u56e0 \u4e8c\u3001\u5faa\u73af\u7834\u89e3 \u4e09\u3001\u4f7f\u7528requests\u4e2d\u7684\u5185\u5b58\u6cc4\u6f0f\u95ee\u9898 \u56db\u3001opencv\u5185\u5b58\u6cc4\u6f0f\uff08\u672a\u89e3\u51b3\u8fc7   \u2026 &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0},"categories":[34],"tags":[],"_links":{"self":[{"href":"\/index.php?rest_route=\/wp\/v2\/posts\/1360"}],"collection":[{"href":"\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1360"}],"version-history":[{"count":1,"href":"\/index.php?rest_route=\/wp\/v2\/posts\/1360\/revisions"}],"predecessor-version":[{"id":1361,"href":"\/index.php?rest_route=\/wp\/v2\/posts\/1360\/revisions\/1361"}],"wp:attachment":[{"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1360"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1360"},{"taxonomy":"post_tag","embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1360"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}