随笔分类 -  python

python
摘要:在接口测试中,需要对接口请求的结果进行判断,如果是异步接口,需要用轮询的方式, 假设列表中返回一批数据,需要对这些数据的结果进行验证,我们可以取出每条数据的结果 放到列表中,从而判断列表中的这些结果的值是否一致,python代码如下: def isreal(list): flag = False f 阅读全文
posted @ 2021-11-05 18:05 maxwell11 阅读(2098) 评论(0) 推荐(0)
摘要:1.pytest官方文档: 官网:https://docs.pytest.org/en/latest/ PYPI地址:https://pypi.org/project/pytest/ 英文文档地址:https://docs.pytest.org/en/stable/ 中文文档地址:https://w 阅读全文
posted @ 2021-01-29 01:55 maxwell11 阅读(620) 评论(1) 推荐(0)
摘要:1.使用深拷贝或浅拷贝时,需要先引入copy import copy <1>.不使用copy的方式 # a = [1, 2, 3] # b=a相当于把a赋值给b,a和b指向的是同一个引用,当a的值发生了改变,b也会随之改变 # b = a # a[0] = 5 # print(a) # [5, 2, 阅读全文
posted @ 2021-01-26 00:53 maxwell11 阅读(133) 评论(0) 推荐(0)
摘要:1.判断 if 条件表达式: <1>.条件表达式为布尔值,如 == ,is ,>,<,=, in 省略的写法,变量存在,执行if 后面的代码: if a: xxxxxxxx 当a 为true时执行if 后面的代码,为false不会执行 # a=0, a=0.0, a=[], a=(), a={}, 阅读全文
posted @ 2021-01-25 22:06 maxwell11 阅读(701) 评论(0) 推荐(0)
摘要:1.元组: <1>.定义:(),不能改值的数组 a = 1,2,3,4,5 print(type(a)) #tuple 单个元组的定义(a,) <2>. 字符串可以直接转成元组: c = '1234' # print(tuple(c)) # ('1', '2', '3', '4') <3>. 索引, 阅读全文
posted @ 2021-01-24 20:23 maxwell11 阅读(390) 评论(0) 推荐(0)
摘要:1.字典,python中的一种数据结构,以key ,value格式存储,是可变数据类型 2.字典的定义:key不能重复,字典的key 可以是字符串或整数 value可以是任意数据类型,可以重复,可以是字符串,列表,字典,元组,布尔值等 3.二维元组或列表可以直接转成字典 a = (('mac', 1 阅读全文
posted @ 2021-01-23 22:58 maxwell11 阅读(411) 评论(0) 推荐(0)
摘要:1.闭包: def func(): print('this is func') def func_inner(): print('this is inner') # func函数执行之前返回内部函数引用 return func_inner a = func()# 调用内部函数 a()#输出: thi 阅读全文
posted @ 2021-01-20 02:08 maxwell11 阅读(95) 评论(0) 推荐(0)
摘要:1.zip函数,系统函数,可以将多个列表合并,生成一个新的列表,返回结果是生成器 # a = [49, 80, 78, 60]# b = ['张三', '李四', '小明', '小红']# d = ['13121111111', '13222222222', '1333333333s3', '134 阅读全文
posted @ 2021-01-20 01:56 maxwell11 阅读(118) 评论(0) 推荐(0)
摘要:1. 类和对象 类--对一类事物的抽象 没有实际意义 对象 真实客观存在的 类的实例化 类的具体化 类的定义 Class 类名(大驼峰命名,首字母大写),默认继承object,可以多继承2.编写一个类 两类内容:属性 变量 行为--函数(方法) 属性 自我独有--成员属性(属于对象) 大家共享的 类 阅读全文
posted @ 2021-01-17 15:55 maxwell11 阅读(138) 评论(0) 推荐(0)
摘要:1.生成器,高阶函数map,reduce 返回的都是生成器对象 下面的结果输出,会初始化一个列表,占用内存空间 # lis = [x*x for x in range(10)]# print(lis) 而使用生成器,返回结果是生成器对象,可以进行迭代,相对于上面,可以节省内存空间,只有在使用的时候, 阅读全文
posted @ 2021-01-17 01:21 maxwell11 阅读(130) 评论(0) 推荐(0)
摘要:import random 1.random.randint 上下边界都包含,随机整数,可能会重复 a = ['python', 'java', 'php', 'c++']# print(a[random.randint(0, len(a) - 1)]) 2.random.random 随机小数,0 阅读全文
posted @ 2021-01-16 22:39 maxwell11 阅读(247) 评论(0) 推荐(0)
摘要:1.如上图所示,获取当前时间,time.time(),返回结果是时间戳,单位是秒 print(time.time()) 2.将时间戳转换成时间元组,time.localtime(time.time()),将当前时间戳转成成时间元组 print(time.localtime(time.time())) 阅读全文
posted @ 2021-01-16 21:54 maxwell11 阅读(150) 评论(0) 推荐(0)
摘要:1. try....except(except1,except2),可以捕获多个异常,如果都未捕获到,则程序终止 try: a=[1,2,3] print(a[4]) except(IndexError, ZeroDivisionError): print('发生了错误') print('1111' 阅读全文
posted @ 2021-01-15 20:38 maxwell11 阅读(133) 评论(0) 推荐(0)
摘要:"""电信号段:133/149/153/173/177/180/181/189/199; 联通号段:130/131/132/145/155/156/166/171/175/176/185/186/166;移动号段:134/135/136/137/138/139/150/151/152/157/158 阅读全文
posted @ 2020-12-31 14:01 maxwell11 阅读(267) 评论(0) 推荐(0)