上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 26 下一页

2020年3月25日

摘要: class Person(object): count = 0 @classmethod def show_people_count(cls): print('显示创建的人数:%s' % cls.count) def __init__(self, name): self.name = name Pe 阅读全文
posted @ 2020-03-25 17:16 yeyu1314 阅读(86) 评论(0) 推荐(0) 编辑
摘要: class Tool(object): count = 0 def __init__(self, name): self.name = name Tool.count += 1 # 定义一个数量的属性,我们就可以通过count知道创建的对象的数量 a = Tool('斧头') b = Tool('弓 阅读全文
posted @ 2020-03-25 17:15 yeyu1314 阅读(88) 评论(0) 推荐(0) 编辑

2020年3月24日

摘要: class Dog(object): def __init__(self, name): self.name = name def game(self): print('%s 蹦蹦跳跳的玩耍' % self.name) class XiaoTiaoDog(Dog): def game(self): 阅读全文
posted @ 2020-03-24 20:12 yeyu1314 阅读(111) 评论(0) 推荐(0) 编辑
摘要: 概念: 并行:指每个cpu独立执行一个任务 并发:指一个或多个cpu同时轮询执行许多的任务 线程的使用标准 注意:传参args后面必须是元组 import time import threading def sing(): for i in range(5): time.sleep(0.5) pri 阅读全文
posted @ 2020-03-24 12:02 yeyu1314 阅读(131) 评论(0) 推荐(0) 编辑
摘要: class Animal: def __init__(self,name): self.name = name def eat(self): print('吃') def drink(self): print('喝') def run(self): print('跑') def sleep(self 阅读全文
posted @ 2020-03-24 07:34 yeyu1314 阅读(92) 评论(0) 推荐(0) 编辑

2020年3月23日

摘要: class Woman: def __init__(self, name, age): self.name = name self.__age = age # 私有属性 def __secret(self): # 私有方法 print('我的年龄是秘密') class Woman: def __in 阅读全文
posted @ 2020-03-23 14:00 yeyu1314 阅读(91) 评论(0) 推荐(0) 编辑
摘要: class Gun: def __init__(self, model): self.model = model self.bullet_count = 0 def add_bullet(self, count): self.bullet_count += count def shoot(self) 阅读全文
posted @ 2020-03-23 12:51 yeyu1314 阅读(179) 评论(0) 推荐(0) 编辑
摘要: class Person: def __init__(self,name,weight): self.name = name self.weight = weight def __str__(self): return '我叫%s,我的体重是%.2f' % (self.name, self.weig 阅读全文
posted @ 2020-03-23 09:28 yeyu1314 阅读(251) 评论(0) 推荐(0) 编辑
摘要: 对比下面的两张图,你就会了解__str__内置函数的作用了 阅读全文
posted @ 2020-03-23 09:07 yeyu1314 阅读(133) 评论(0) 推荐(0) 编辑
摘要: del与init相反 class Cat: # 定义累 ''' __init__ : 方法是专门用来定义一个类,具有哪些属性的方法。 ''' def __init__(self, name, age): print('这是一个初始化的方法') self.name = name self.age = 阅读全文
posted @ 2020-03-23 08:51 yeyu1314 阅读(99) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 26 下一页