{"id":84006,"date":"2020-05-13T16:58:50","date_gmt":"2020-05-13T08:58:50","guid":{"rendered":"http:\/\/4563.org\/?p=84006"},"modified":"2020-05-13T16:58:50","modified_gmt":"2020-05-13T08:58:50","slug":"%e9%9d%a2%e8%af%95%e9%a2%98%e5%88%86%e6%9e%90-python-%e9%87%8c%e9%9d%a2%e5%a6%82%e4%bd%95%e6%8b%b7%e8%b4%9d%e4%b8%80%e4%b8%aa%e5%af%b9%e8%b1%a1%ef%bc%9f%ef%bc%88%e8%b5%8b%e5%80%bc%ef%bc%8c%e6%b5%85","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=84006","title":{"rendered":"[\u9762\u8bd5\u9898\u5206\u6790] Python \u91cc\u9762\u5982\u4f55\u62f7\u8d1d\u4e00\u4e2a\u5bf9\u8c61\uff1f\uff08\u8d4b\u503c\uff0c\u6d45\u62f7\u8d1d\uff0c\u6df1\u62f7\u8d1d\u7684\u533a\u522b\uff09"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  [\u9762\u8bd5\u9898\u5206\u6790] Python \u91cc\u9762\u5982\u4f55\u62f7\u8d1d\u4e00\u4e2a\u5bf9\u8c61\uff1f\uff08\u8d4b\u503c\uff0c\u6d45\u62f7\u8d1d\uff0c\u6df1\u62f7\u8d1d\u7684\u533a\u522b\uff09               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : julyedu <\/span>  <span><i><\/i> 2<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u89e3\u6790\uff1a<\/p>\n<p>\u8d4b\u503c\uff08=\uff09\uff0c\u5c31\u662f\u521b\u5efa\u4e86\u5bf9\u8c61\u7684\u4e00\u4e2a\u65b0\u7684\u5f15\u7528\uff0c\u4fee\u6539\u5176\u4e2d\u4efb\u610f\u4e00\u4e2a\u53d8\u91cf\u90fd\u4f1a\u5f71\u54cd\u5230\u53e6\u4e00\u4e2a\u3002<\/p>\n<p>\u6d45\u62f7\u8d1d\uff1a\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5bf9\u8c61\uff0c\u4f46\u5b83\u5305\u542b\u7684\u662f\u5bf9\u539f\u59cb\u5bf9\u8c61\u4e2d\u5305\u542b\u9879\u7684\u5f15\u7528\uff08\u5982\u679c\u7528\u5f15\u7528\u7684\u65b9\u5f0f\u4fee\u6539\u5176\u4e2d\u4e00\u4e2a\u5bf9\u8c61\uff0c\u53e6\u5916\u4e00\u4e2a\u4e5f\u4f1a\u4fee\u6539\u6539\u53d8\uff09{1,\u5b8c\u5168\u5207\u7247\u65b9\u6cd5\uff1b 2\uff0c\u5de5\u5382\u51fd\u6570\uff0c\u5982 list()\uff1b 3\uff0ccopy \u6a21\u5757\u7684 copy()\u51fd\u6570}<\/p>\n<p>\u6df1\u62f7\u8d1d\uff1a\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5bf9\u8c61\uff0c\u5e76\u4e14\u9012\u5f52\u7684\u590d\u5236\u5b83\u6240\u5305\u542b\u7684\u5bf9\u8c61\uff08\u4fee\u6539\u5176\u4e2d\u4e00\u4e2a\uff0c\u53e6\u5916\u4e00\u4e2a\u4e0d\u4f1a\u6539\u53d8\uff09{copy \u6a21\u5757\u7684 deep.deepcopy()\u51fd\u6570}<\/p>\n<p>\u987a\u4fbf\u95ee\u4e0b\u5927\u5bb6\uff0c\u73b0\u5728 V2EX \u7684\u5144\u5f1f\u4eec\u8fd8\u6709\u9700\u8981 python \u8bfe\u7a0b\u7684\u5417\uff0c\u6211\u53ef\u4ee5\u514d\u8d39\u9001\u5927\u5bb6\u4e00\u4e9b\u4f18\u8d28\u8bfe\u7a0b\uff0c\u7edd\u5bf9\u514d\u8d39\uff01<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>15<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"1540126\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : jmc891205 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             a = 1<br \/>b = a<br \/>\u8fd9\u7b97\u8d4b\u503c\u3001\u6d45\u62f7\u8d1d\u8fd8\u662f\u6df1\u62f7\u8d1d                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1540127\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lxd152 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @jmc891205 b \u6307\u5411 a \u7684\u5185\u5b58\uff0c\u7b97\u6d45\u62f7\u8d1d\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1540128\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Vegetable <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f60\u4eec\u4e24\u4e2a\u7ed9\u6211\u6574\u695e\u4e86\uff0c\u4e00\u5927\u54e5\u662f\u8003\u6559\u8fd8\u662f\u771f\u95ee\u554a\u3002<br \/>python \u91cc\u6570\u5b57\u672c\u8eab\u662f\u4e0d\u53ef\u53d8\u5bf9\u8c61\uff0c\u5e76\u4e0d\u5b58\u5728 shallow copy \u548c deep copy \u7684\u533a\u522b\uff0c\u4e00\u65e6\u533a\u5206\u6df1\u6d45\uff0c\u90a3\u5fc5\u7136\u662f\u590d\u5408\u5bf9\u8c61\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1540129\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : kkk330 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u522b\u5fd8\u4e86\u5c0f\u6574\u6570\u6c60                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1540130\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : jhdxr <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @lxd152 \u5148\u4e0d\u8bf4\u4e00\u8fd9\u4e2a\u4f8b\u5b50\u662f\u6570\u5b57\u3002\u3002\u3002\u5c31\u4f60\u5355\u7eaf\u8fd9\u63cf\u8ff0\u300e b \u6307\u5411 a \u7684\u5185\u5b58\u300f\u8fd9\u660e\u663e\u4e5f\u662f\u8d4b\u503c\uff08\u6309\u7167\u6b63\u6587\u4e2d\u7684\u4e09\u79cd\u5206\u7c7b\u65b9\u5f0f\uff09\u554a\u3002\u3002\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1540131\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lxd152 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @jhdxr \u554a\u3002\u3002\u6211\u8bf4\u9519\u4e86\u561b\u3002\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1540132\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lxd152 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @jhdxr <br \/>&gt;&gt;&gt; a = 1<br \/>&gt;&gt;&gt; b = a<br \/>&gt;&gt;&gt; id(a)<br \/>140725512607392<br \/>&gt;&gt;&gt; id(b)<br \/>140725512607392                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1540133\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : youngce <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @lxd152 #7 <\/p>\n<p>\uff40\uff40\uff40<br \/>&gt;&gt;&gt; a= 1<br \/>&gt;&gt;&gt; b=a<br \/>&gt;&gt;&gt; a=2<br \/>&gt;&gt;&gt; b<br \/>1<br \/>&gt;&gt;&gt; a=[1,2]<br \/>&gt;&gt;&gt; c=[1,2]<br \/>&gt;&gt;&gt; d = c<br \/>&gt;&gt;&gt; c.append(3)<br \/>&gt;&gt;&gt; c<br \/>[1, 2, 3]<br \/>&gt;&gt;&gt; d<br \/>[1, 2, 3]<\/p>\n<p>\uff40\uff40\uff40                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1540134\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lxd152 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @youngce \u660e\u767d\u4e86\u3002\u3002\u611f\u8c22\uff0c\u6211\u518d\u591a\u770b\u770b\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1540135\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : jmc891205 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Vegetable \u54c8\u54c8 \u6bd5\u7adf python \u91cc\u4e07\u7269\u7686 object \u561b                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1540136\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : qiaobeier <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             yo\uff0c\u6211\u5f88\u559c\u6b22\u7528\u8fd9\u4e2a\u9898\u76ee\u8003\u524d\u7aef\u9762\u8bd5\u8005\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1540137\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : jhdxr <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @jmc891205 \uff1f\uff1f\uff1f\u4f60\u662f\u8ba4\u771f\u7684\uff1f ruby \u624d\u662f\u4e07\u7269\u7686 object \u5427\u3002\u3002\u3002<\/p>\n<p>\u8865\u5145\uff1a<br \/>\u5173\u4e8e\u8fd9\u4e00\u70b9\u6211\u53bb\u641c\u4e86\u4e0b\uff0c\u6211\u7684\u786e\u641c\u5230<br \/>&gt; Everything in Python is an object, and almost everything has attributes and methods. All functions have a built-in attribute __doc__, which returns the doc string defined in the function&#8217;s source code. The sys module is an object which has (among other things) an attribute called path. And so forth.<br \/>&gt; Still, this begs the question. What is an object? Different programming languages define \u201cobject\u201d in different ways. In some, it means that all objects must have attributes and methods; in others, it means that all objects are subclassable. In Python, the definition is looser; some objects have neither attributes nor methods (more on this in Chapter 3), and not all objects are subclassable (more on this in Chapter 5). But everything is an object in the sense that it can be assigned to a variable or passed as an argument to a function (more in this in Chapter 4).<\/p>\n<p>\u6211\u89c9\u5f97\u4e00\u4e2a\u6ca1\u6709\u5c5e\u6027\uff0c\u4e5f\u6ca1\u6709\u65b9\u6cd5\uff0c\u4e5f\u4e0d\u80fd\u88ab\u5b50\u7c7b\u5316\u7684\u4e1c\u897f\uff0c\u628a\u5b83\u5b9a\u4e49\u4e3a object \u6709\u70b9\u7275\u5f3a\uff1f                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1540138\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : chizuo <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5176\u5b9e python \u5173\u4e8e\u6570\u503c\uff0c\u5e76\u4e0d\u5b58\u5728\u5f15\u7528\u4e00\u8bf4\uff0c\u503c\u76f8\u540c\u65f6\uff0c\u6307\u5411\u540c\u4e00\u4e2a\u5730\u5740\u3002\u503c\u4e0d\u540c\u65f6\uff0c\u81ea\u7136\u5730\u5740\u5c31\u53d8\u4e86\u3002 <br \/>&#8220;`<br \/>&gt;&gt;&gt; x = 1<br \/>&gt;&gt;&gt; y = 1<br \/>&gt;&gt;&gt; id(x) == id(y)<br \/>True<br \/>&gt;&gt;&gt; x = 2<br \/>&gt;&gt;&gt; id(x) == id(y)<br \/>False<br \/>&gt;&gt;&gt;<br \/>&#8220;`                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1540139\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : julyedu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5144\u5f1f\u4eec\u6709\u9700\u8981 Python \u8bfe\u7a0b\u7684\u5417\uff0c\u6211\u53ef\u4ee5\u514d\u8d39\u9001\u5927\u5bb6\u4e00\u4e9b                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1540140\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : julyedu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Vegetable @chizuo @jhdxr @jmc891205 @kkk330 @lxd152 @qiaobeier @youngce                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>[\u9762\u8bd5\u9898\u5206\u6790] Python \u91cc\u9762&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\/84006"}],"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=84006"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/84006\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=84006"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=84006"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=84006"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}