跳转到帖子
  • 游客您好,欢迎来到黑客世界论坛!您可以在这里进行注册。

    赤队小组-代号1949(原CHT攻防小组)在这个瞬息万变的网络时代,我们保持初心,创造最好的社区来共同交流网络技术。您可以在论坛获取黑客攻防技巧与知识,您也可以加入我们的Telegram交流群 共同实时探讨交流。论坛禁止各种广告,请注册用户查看我们的使用与隐私策略,谢谢您的配合。小组成员可以获取论坛隐藏内容!

    TheHackerWorld官方

推荐的帖子

面向对象编程

类:从一堆对象中以抽象的方式把相同的特征归类得到。

  1. 抽象类
  2. 实列

子类抽象为父类,子类继承父类特征。
类实例化为实例,实例抽象为类。

    class Human(object):

        century = 21

        def __init__(self, name, age):
            self.name = name
            self.age = age
            print("init work")

        def speak(self, language):
            print('%s has speak %s ability'% (self.name, language))

        def write(self, word):
            print('%s has write %s ability'% (self.name, word))

        def walk(self):
            print('%s has walk ability'% self)
    Allen = Human('Allen-Cart', 16) # 输出结果:init work
    print(Allen.name, Allen.age) # 输出结果:Allen-Cart 16

    print(Allen.speak,Allen.write,Allen.walk)
    # <bound method Human.speak of <__main__.Human object at 0x10ab50160>>
    # <bound method Human.write of <__main__.Human object at 0x10ab50160>>
    # <bound method Human.walk of <__main__.Human object at 0x10ab50160>>

    print(Human.speak,Human.write,Human.walk)
    # <function Human.speak at 0x110ba5378>
    # <function Human.write at 0x110ba5400>
    # <function Human.walk at 0x110ba5488>

    Allen.speak("Chinese") # Allen-Cart has speak Chinese ability
    Allen.write("Chinese") # Allen-Cart has write Chinese ability
    Allen.walk() # <__main__.Human object at 0x10ab50160> has walk ability.

    Human.walk('James') # James has walk ability
链接帖子
意见的链接
分享到其他网站

黑客攻防讨论组

黑客攻防讨论组

    You don't have permission to chat.
    • 最近浏览   0位会员

      • 没有会员查看此页面。
    ×
    ×
    • 创建新的...