会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
dyjnicole
博客园
首页
新随笔
联系
订阅
管理
2023年3月29日
python字典合并
摘要: # 合并字典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
阅读(42)
评论(0)
推荐(0)
2023年3月28日
python-列表去重
摘要: # 列表去重的方法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
阅读(92)
评论(0)
推荐(0)
2023年3月22日
pytest运行结果乱码处理
摘要: pytest终端打印结果,中文乱码,解决方式: 第一种方式:在pytest.ini文件中添加一行代码:disable_test_id_escaping_and_forfeit_all_rights_to_community_support = True 第二种方式,conftest.py中添加钩子函
阅读全文
posted @ 2023-03-22 15:36 dyjnicole
阅读(465)
评论(0)
推荐(0)
2023年3月21日
mock技术之moco
摘要: 地址: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
阅读(52)
评论(0)
推荐(0)
2023年3月17日
Python requests 中文乱码问题
摘要: print('接口响应体 》', res.text) # 输出结果中文乱码 解决方案:可以在请求成功时设置对应的编码,例如:res = requests.request(method="GET", url=url, params=in_data, cookies=cookie)res.encodin
阅读全文
posted @ 2023-03-17 16:46 dyjnicole
阅读(108)
评论(0)
推荐(0)
python中的列表排序
摘要: # 列表排序:'''# 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
阅读(221)
评论(0)
推荐(0)
2023年3月16日
python判断是否是合法的ip地址
摘要: 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
阅读(57)
评论(0)
推荐(0)
python用递归方式去掉首尾空格
摘要: # 递归去除空格 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
阅读(29)
评论(0)
推荐(0)
2023年3月9日
python连接mysql
摘要: 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
阅读(22)
评论(0)
推荐(0)
python中的json数组排序,取最小最大值
摘要: 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
阅读(305)
评论(0)
推荐(0)
下一页
公告