摘要: class F: def __init__(self, name): self.name = name def __getattr__(self, item): return '__getattr__'obj = F('tom')print(obj.name)print(obj.age)当调用类中的 阅读全文
posted @ 2019-12-17 19:50 菜菜_包包 阅读(1644) 评论(0) 推荐(0)
摘要: class F: def __init__(self, name, age): self.name = name self.age = age obj = F('tom', 20)s = obj.__dict__print(s) # {'name': 'tom', 'age': 20}__dict_ 阅读全文
posted @ 2019-12-17 19:43 菜菜_包包 阅读(2589) 评论(0) 推荐(0)
摘要: class F: def __str__(self): return 'hello china' def __int__(self): return 123res = F()print(res) #结果是hello chinaprint(int(res)) #结果是123创建的对象时,会自动去寻找类 阅读全文
posted @ 2019-12-16 15:46 菜菜_包包 阅读(4173) 评论(0) 推荐(1)
摘要: class F: def __call__(self, *args, **kwargs): print('执行__call__') s = F()s() 先给类创建一个对象,直接通过对象来执行,就会自动去执行类中的__call__函数,如上面的执行结果就是“执行__call__” 阅读全文
posted @ 2019-12-16 15:33 菜菜_包包 阅读(1094) 评论(0) 推荐(0)
摘要: class F: def __init__(self): print('hello china')__init__ 是构造函数,初始化类,每当调用类的时候,就会自动执行这个函数比如:执行 F() 的时候,会自动执行__init__函数,就会自动打印出“hello china” 阅读全文
posted @ 2019-12-16 15:28 菜菜_包包 阅读(4668) 评论(0) 推荐(0)
摘要: class Father: def f1(self): print('hello')class Son(Father): def f1(self): super(Son, self).f1() # super格式:(子类,对象).重写的方法 print('world')obj = Son()obj. 阅读全文
posted @ 2019-12-15 15:47 菜菜_包包 阅读(129) 评论(0) 推荐(0)
摘要: from setting import *import datetimesys.path.append(LIB_DIR)# print(LIB_DIR)class TimeFormat: '''格式化时间''' def now_time(self, format): ''' 当前时间 :param 阅读全文
posted @ 2019-12-12 14:21 菜菜_包包 阅读(664) 评论(0) 推荐(0)
摘要: # -*- coding:utf-8 -*-from setting import *import osimport sys# print(DATA_DIR)class DataManage(): '''数据的存储和读取''' def __init__(self,): sys.path.append 阅读全文
posted @ 2019-12-12 14:21 菜菜_包包 阅读(374) 评论(0) 推荐(0)
摘要: def nrun(): report = ('report_' + ('%s') % time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()) + '.html').replace('\\', '/') suite = unittest.default 阅读全文
posted @ 2019-12-12 14:19 菜菜_包包 阅读(1097) 评论(0) 推荐(0)
摘要: def __save_screenshot(self): self.driver.save_screenshot('full_snap.png') self.page_snap_obj = Image.open('full_snap.png') return self.page_snap_objde 阅读全文
posted @ 2019-12-10 15:47 菜菜_包包 阅读(1398) 评论(0) 推荐(0)