{"id":201567,"date":"2020-11-25T00:01:18","date_gmt":"2020-11-24T16:01:18","guid":{"rendered":"http:\/\/4563.org\/?p=201567"},"modified":"2020-11-25T00:01:18","modified_gmt":"2020-11-24T16:01:18","slug":"%e8%af%b7%e6%95%99%e4%b8%80%e4%b8%aa%e5%85%b3%e4%ba%8e-python-%e5%ae%9e%e4%be%8b%e5%8c%96%e5%86%85%e5%ad%98%e5%9c%b0%e5%9d%80%e7%9a%84%e5%9f%ba%e7%a1%80%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=201567","title":{"rendered":"\u8bf7\u6559\u4e00\u4e2a\u5173\u4e8e Python \u5b9e\u4f8b\u5316\u5185\u5b58\u5730\u5740\u7684\u57fa\u7840\u95ee\u9898"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u8bf7\u6559\u4e00\u4e2a\u5173\u4e8e Python \u5b9e\u4f8b\u5316\u5185\u5b58\u5730\u5740\u7684\u57fa\u7840\u95ee\u9898               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : foxyier <\/span>  <span><i><\/i> 0<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\">                        \u95ee\u9898\u63cf\u8ff0\uff1a \u5faa\u73af\u6267\u884c\u4ee5\u4e0b\u4e24\u4e2a\u64cd\u4f5c: \u300c 1. \u521d\u59cb\u5316\u4e00\u4e2a\u5b9e\u4f8b\uff0c2. \u8f93\u51fa\u5b9e\u4f8b\u7684\u5185\u5b58\u5730\u5740\u300d, \u53d1\u73b0\u6bcf\u6b21\u8f93\u51fa\u7684\u5185\u5b58\u5730\u5740\u5728\u4e24\u4e2a\u5185\u5b58\u5730\u5740\u4e2d\u6765\u56de\u8df3\u52a8\uff0c \u4f46\u662f\u628a\u8fd9\u4e24\u4e2a\u64cd\u4f5c\u653e\u5165\u51fd\u6570\u4e2d\u8c03\u7528\uff0c \u6bcf\u6b21\u8f93\u51fa\u7684\u5185\u5b58\u5730\u5740\u5c31\u76f8\u540c\u4e86, \u4e0d\u592a\u61c2\u5177\u4f53\u539f\u7406\uff0c \u76ee\u524d\u731c\u6d4b\u662f\u8bed\u8a00\u89e3\u91ca\u7684\u8fc7\u7a0b\u4e2d\u505a\u4e86\u7f13\u5b58\uff1f \u5982\u679c\u662f\u8fd9\u6837\u7684\u8bdd\uff0c \u5355\u4f8b\u6a21\u5f0f\u7684\u5e94\u7528\u573a\u666f\u611f\u89c9\u662f\u4e0d\u662f\u5c31\u5f88\u5c11\u4e86?<\/p>\n<p>\u793a\u4f8b 1:<br \/>for i in range(5):<br \/> c = Class1()<br \/> print id(c)<\/p>\n<p>\u793a\u4f8b\u8f93\u51fa:<\/p>\n<p>4467795088<br \/>4467795152<br \/>4467795088<br \/>4467795152<br \/>4467795088<\/p>\n<p>\u793a\u4f8b 2:<\/p>\n<p>def run():<br \/> c = Class1()<br \/> print id(c)<\/p>\n<p>for i in range(5):<br \/> run()<\/p>\n<p>\u793a\u4f8b\u8f93\u51fa:<\/p>\n<p>4566115472<br \/>4566115472<br \/>4566115472<br \/>4566115472<br \/>4566115472<\/p>\n<p>1. \u60f3\u8bf7\u6559\u4e00\u4e0b\u4e3a\u4ec0\u4e48\u8fd9\u4e24\u4e2a\u64cd\u4f5c\u5728\u51fd\u6570\u4e2d\u8fd0\u884c\u65f6\uff0c\u8f93\u51fa\u7684\u5b9e\u4f8b\u5185\u5b58\u5730\u5740\u76f8\u540c.<br \/>2. \u60f3\u8bf7\u6559\u4e00\u4e0b\u4e3a\u4ec0\u4e48\u91c7\u7528\u7b2c\u4e00\u79cd\u65b9\u5f0f\u7684\u65f6\u5019\uff0c\u5b9e\u4f8b\u7684\u5185\u5b58\u5730\u5740\u5728\u4e24\u4e2a\u5185\u5b58\u5730\u5740\u4e2d\u6765\u56de\u8df3\u52a8      <\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>3<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"4306689\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : luoleng <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u793a\u4f8b 1 \u4e2d\uff0c\u5148\u662f\u521b\u5efa\u4e00\u4e2a Class1 \u5b9e\u4f8b\uff08 m \uff09\uff0c\u7136\u540e\u628a\u5b83\u8d4b\u4e88\u53d8\u91cf c\uff0c\u65b0\u4e00\u8f6e for \u5faa\u73af\u7684\u65f6\u5019\uff0c\u53c8\u91cd\u65b0\u521b\u5efa\u4e00\u4e2a Class1 \u5b9e\u4f8b\uff08 n \uff09\uff0c\u7136\u540e\u53c8\u628a\u5b83\u8d4b\u4e88\u53d8\u91cf c\uff0c\u8fd9\u4e2a\u65f6\u5019\u56e0\u4e3a\u5b9e\u4f8b m \u6ca1\u6709\u88ab\u5f15\u7528\u4e86\uff0c\u6240\u4ee5\u4f1a\u88ab\u9500\u6bc1\u3002\u4e4b\u540e\u7684\u5faa\u574f\u53c8\u662f\u5728 m \u7684\u539f\u5730\u5740\u4e0a\u521b\u5efa m1\uff0c\u7136\u540e\u9500\u6bc1 n\u2026\u2026<br \/>\u793a\u4f8b 2 \u4e2d\uff0c\u51fd\u6570\u6267\u884c\u5b8c\u540e\u5728\u51fd\u6570\u4f53\u5185\u521b\u5efa\u7684\u53d8\u91cf\u5c31\u88ab\u9500\u6bc1\u4e86\uff1b\u4e4b\u540e\u7684\u5b9e\u4f8b\u4e5f\u662f\u5728\u539f\u6765\u5b9e\u4f8b\u7684\u5730\u5740\u4e0a\u521b\u5efa\u7684\uff1b<br \/>\u81f3\u4e8e\u65b0\u5b9e\u4f8b\u4e3a\u4ec0\u4e48\u4f1a\u5728\u5df2\u88ab\u9500\u6bc1\u7684\u65e7\u5b9e\u4f8b\u5730\u5740\u4e0a\u521b\u5efa\uff0c\u6211\u59d1\u4e14\u8ba4\u4e3a\u662f python \u81ea\u5df1\u5185\u5b58\u4f18\u5316\u7684\u4e00\u79cd\u7ed3\u679c\u5427\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4306690\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : gwy15 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e0a\u8bf4\u5f97\u5bf9\uff0c\u8981\u5230\u7b2c\u4e8c\u6b21 c = Class1() \u7684\u65f6\u5019\u624d\u4f1a\u5931\u53bb\u4e0a\u4e00\u4e2a\u8fed\u4ee3\u7684\u5f15\u7528\uff0c\u7136\u540e\u624d\u4f1a\u8fdb\u884c GC \u3002<\/p>\n<p>\u5982\u679c\u6539\u6210 <\/p>\n<p>for i in range(5):<br \/>&#8230;.c = Class1()<br \/>&#8230;.print(f&#8217;0x{id(c):x}&#8217;)<br \/>&#8230;.del c<\/p>\n<p>\u5c31\u4f1a\u53d8\u6210\u4e00\u6837\u7684\u5730\u5740\u4e86                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4306691\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : foxyier <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @luoleng @gwy15 \u7406\u89e3\u4e86\uff0c \u591a\u8c22                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u8bf7\u6559\u4e00\u4e2a\u5173\u4e8e Python \u5b9e\u4f8b\u5316&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/201567"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=201567"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/201567\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=201567"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=201567"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=201567"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}