摘要: list.sort( key=None, reverse=False) 参数 key -- 主要是用来进行比较的元素,只有一个参数,具体的函数的参数就是取自于可迭代对象中,指定可迭代对象中的一个元素来进行排序。此key只是用来做排序的标准,不会改变列表 reverse -- 排序规则,reverse 阅读全文
posted @ 2022-03-29 20:29 焰红火 阅读(349) 评论(0) 推荐(0)
摘要: ##1.闭包的介绍 面向过程编程(函数)和面向对象编程(对象)都是一种编程范式,函数和对象本质是将代码以某种逻辑组织起来,提高代码的复用性。而闭包也是一种代码组织的方式,同样也会提高代码的复用性。 不同的语言实现闭包的方式不同。Python以函数对象为基础,为闭包这一语法结构提供支持的。Python 阅读全文
posted @ 2022-01-21 16:16 焰红火 阅读(45) 评论(0) 推荐(0)
摘要: ##1. curl介绍 CURL,全称Command Line URL Viewer,是一个Linux命令行工具,能从服务器下载数据,也能往服务器上发送数据,支持多种协议。 Postman和浏览器在给服务器发送请求时,会接收一个cookies,再次发送请求的时候,会默认将cookies一起发送出去。 阅读全文
posted @ 2022-01-20 16:29 焰红火 阅读(743) 评论(0) 推荐(0)
摘要: 第三方库CSV中提供了2个类来写CSV文件 csv.writer class csv.writer class provides two methods for writing to CSV. They are writerow() and writerows(). writerow(): This 阅读全文
posted @ 2022-01-17 17:09 焰红火 阅读(86) 评论(0) 推荐(0)
摘要: 根据文件名来获取文件路径,要注意此脚本放在不同的位置运行会得到不同的结果 root是顶层文件,dirs是root下的子文件夹。 import os base_dir = os.path.split(os.path.split(os.path.abspath(__file__))[0])[0] #os 阅读全文
posted @ 2022-01-10 15:57 焰红火 阅读(118) 评论(0) 推荐(0)
摘要: pytest fixture 1. 通过conftest.py 共享fixture @pytest.fixture()装饰器用于声明函数是一个fixture,如果测试用例的参数列表中包含fixture, pytest会优先搜索该测试用例所在的模块,然后搜索conftest.py文件。 conftes 阅读全文
posted @ 2022-01-09 20:20 焰红火 阅读(96) 评论(0) 推荐(0)
摘要: 测试文件的命名规则 1.测试文件应该命名为test_<something>.py或者<something>_test.py 2.测试类应该命名为Test<something>.py 3.测试函数和测试类方法应该命名为test_<something> Pytest 基础命令 pytest --hlep 阅读全文
posted @ 2022-01-08 20:55 焰红火 阅读(70) 评论(0) 推荐(0)
摘要: ##读写Excel文件 xls 是Excel 2007之前的版本,xlsx 是Excel 2007之后的版本,xlrd和xlwt 是用于较老的版本 openpyxl是官方推荐使用的第三方库.如果在Excel文件中插入图片之类的,需要pip install pillow # 读取Excel文件 imp 阅读全文
posted @ 2022-01-07 14:34 焰红火 阅读(147) 评论(0) 推荐(0)
摘要: Given an integer array nums, return the third distinct maximum number in this array. If the third maximum does not exist, return the maximum number. 第 阅读全文
posted @ 2021-12-29 21:08 焰红火 阅读(33) 评论(0) 推荐(0)
摘要: def func(): try: x = 1 y = 0 assert x + y == 0, 'x +y != 0, x + y is {}'.format(x + y) except AssertionError as err: # raise AssertionError('abc ') # 阅读全文
posted @ 2021-12-28 23:08 焰红火 阅读(109) 评论(0) 推荐(0)