
python
文章平均质量分 53
饭_团
这个作者很懒,什么都没留下…
展开
-
pytest学习
一、pytest 安装安装:pip install pytest查看版本:pytest --version二、简单测试1、创建testcase.py,编写一个测试用例def test(a): assert a == 1 #使用assert 判断测试用例是否成功2、运行仅运行一个文件:pytest test.py运行目录下所有测试用例:pytest testcase/运行单个测试用例:pytest test_login.py::test_1(函数形式测试用例).原创 2022-03-22 11:21:03 · 439 阅读 · 1 评论 -
python 文件处理
shutil.rmtree(filepath):递归的删除文件夹os.rmdir(dir):删除空文件夹os.path.exists(outdir):判断文件是否存在os.makedirs(outdir):创建文件夹os.listdir(path):列出文件夹下的子文件with open(filename,‘a+’)as f: 打开文件mode:r 模式1、如果文件存在,打开文件,光标置于开头,原数据可读,不可写入新数据;2、如果文件不存在,报错;r+ 模式1、如果文件存在,打开文件,原创 2021-06-19 15:51:41 · 372 阅读 · 0 评论 -
python中英文混合字符串对齐
python字符串对齐可以使用字符串的 ljust() , rjust() 和 center() 方法,ljust() 字符串靠左,需要填写两个参数,第一个参数为长度,z原创 2021-06-19 15:50:45 · 2219 阅读 · 0 评论 -
python requests库的使用
一、所需头文件import requestsfrom requests.auth import HTTPBasicAuthimport json二、请求信息url = ""auth = HTTPBasicAuth("account","api_token")#如果auth使用不通过的话,可以再header加入Cookieheader ={ "Acept" = "", "Content-Type":"" "Cookie":""}data = { "params" = "v原创 2021-02-27 15:43:36 · 138 阅读 · 0 评论