摘要: # 合并字典dic_a = {"user": "aa", "pwd": "123"}dic_b = {"age": 12, "sex": "男"}# 1.update方法# dic_a.update(dic_b)# print(dic_a)# 2.字典解包# dic_new = {**dic_a, 阅读全文
posted @ 2023-03-29 12:53 dyjnicole 阅读(21) 评论(0) 推荐(0) 编辑
摘要: # 列表去重的方法list1 = [9, 1, 2, 3, 4, 2, 3, 1, 3, 5]# 1.转成set再转listlist2 = list(set(list1))# print(list2)# 使用set方式会改变原来的顺序,可以通过sort和sorted方法还原顺序list3 = lis 阅读全文
posted @ 2023-03-28 16:07 dyjnicole 阅读(62) 评论(0) 推荐(0) 编辑
摘要: pytest终端打印结果,中文乱码,解决方式: 第一种方式:在pytest.ini文件中添加一行代码:disable_test_id_escaping_and_forfeit_all_rights_to_community_support = True 第二种方式,conftest.py中添加钩子函 阅读全文
posted @ 2023-03-22 15:36 dyjnicole 阅读(351) 评论(0) 推荐(0) 编辑
摘要: 地址:https://github.com/dreamhead/moco,可以查看详细文档和源码 下载地址:https://repo1.maven.org/maven2/com/github/dreamhead/moco-runner/ 选择需要的版本下载jar包,放入目录,例如D:\mock fo 阅读全文
posted @ 2023-03-21 21:24 dyjnicole 阅读(24) 评论(0) 推荐(0) 编辑
摘要: print('接口响应体 》', res.text) # 输出结果中文乱码 解决方案:可以在请求成功时设置对应的编码,例如:res = requests.request(method="GET", url=url, params=in_data, cookies=cookie)res.encodin 阅读全文
posted @ 2023-03-17 16:46 dyjnicole 阅读(90) 评论(0) 推荐(0) 编辑
摘要: # 列表排序:'''# 1.通过sort()方法排序,直接修改原列表def sort_list(list_data, rev=False): L.sort() # reverse默认False升序 if rev: L.sort(reverse=True) return LL = [324, 23, 阅读全文
posted @ 2023-03-17 11:20 dyjnicole 阅读(183) 评论(0) 推荐(0) 编辑
摘要: def ip_fun(ip_str: str): ip_list = ip_str.split(".") flag = True for ip in ip_list: if ip.isdigit() and len(ip_list) == 4 and 0 <= int(ip) <= 255: con 阅读全文
posted @ 2023-03-16 16:51 dyjnicole 阅读(28) 评论(0) 推荐(0) 编辑
摘要: # 递归去除空格 def trip_str(s): if s[0] == ' ': return trip_str(s[1:]) elif s[-1] == " ": return trip_str(s[:-1]) else: return s print(trip_str("a b ")) pri 阅读全文
posted @ 2023-03-16 16:49 dyjnicole 阅读(17) 评论(0) 推荐(0) 编辑
摘要: conn = pymysql.connect(host="127.0.0.1", port=3306, user="root", password="root", database="mydatabase", charset="utf8")cur = conn.cursor(cursor=pymys 阅读全文
posted @ 2023-03-09 11:47 dyjnicole 阅读(15) 评论(0) 推荐(0) 编辑
摘要: from operator import itemgetter json_array = [{"time": 20150312, "value": "c"}, {"time": 20150301, "value": "a"}, {"time": 20150305, "value": "b"}]jso 阅读全文
posted @ 2023-03-09 11:45 dyjnicole 阅读(245) 评论(0) 推荐(0) 编辑