{"id":849,"date":"2018-07-17T18:15:13","date_gmt":"2018-07-17T10:15:13","guid":{"rendered":"http:\/\/www.sniper97.cn\/?p=849"},"modified":"2018-07-17T18:15:13","modified_gmt":"2018-07-17T10:15:13","slug":"%e7%ac%ac%e5%85%ad%e8%ae%b2%ef%bc%9a%e7%b1%bb","status":"publish","type":"post","link":"http:\/\/www.sniper97.cn\/index.php\/note\/python\/849\/","title":{"rendered":"\u7b2c\u516d\u8bb2\uff1a\u7c7b"},"content":{"rendered":"<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\"># -*- coding:utf-8 -*-\n# \u7c7b\nclass Human(object):\n    def __init__(self, name):  # \u76f8\u5f53\u4e8e\u6784\u9020\u65b9\u6cd5\n        self.name = name\n        # print name\nHuman_a = Human(\"alan\")\nclass human(object):\n    pass\nhuman_b = human()\nhuman_b.name = \"alan\"\n# print human_b.name\nhuman_c = human()\nhuman_c.name = \"bob\"\n# print human_c.name\nclass human1(object):  # \u7c7b\u4e2d\u7684\u65b9\u6cd5\n    def __init__(self, name):\n        self.name = name\n   # def wolk(self):\n        # print self.name + \" is walking\"\nhuman_d = human1(\"alan\")\nhuman_d.wolk()\nclass human2(object):\n    def __init__(self, name):\n        self.__name = name\n    # def wolk(self):\n        # print self.__name + \" is walking in human2\"\n    def get_name(self):  # get set \u65b9\u6cd5 \u548cjava\u7b49\u4e00\u6837\n        return self.__name\n    def set_name(self, name):\n        self.__name = name\nhuman_d = human2(\"alan\")\n# print human_d.get_name()\n# print human_d.__name          # \u62a5\u9519 \u8bbf\u95ee\u4e0d\u5230\nhuman_d.set_name(\"bob\")\nhuman_d.wolk()\n# \u7ee7\u627f &amp; \u591a\u6001\nclass man(Human):  # \u7ee7\u627f &amp; \u589e\u52a0\u65b9\u6cd5\n    def __init__(self, name, hasWife):\n        # self.__name = name\n        super(man, self).__init__(name)  # \u53ef\u4ee5\u7528super\u8c03\u7528\u7236\u7c7b\u7684\u6784\u9020\u51fd\u6570\n        self.__hasWife = hasWife\n    # def smoke(self):\n        # print \"A man maybe smoke\"\n   #  def drink(self):\n        # print \"A man maybe drink\"\nmanA = man(\"bob\", False)\nmanA.drink()\nmanA.smoke()\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p># -*- coding:utf-8 -*- # \u7c7b class Human(object): de [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[24],"tags":[],"views":1640,"_links":{"self":[{"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/posts\/849"}],"collection":[{"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/comments?post=849"}],"version-history":[{"count":0,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/posts\/849\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/media?parent=849"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/categories?post=849"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/tags?post=849"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}