随笔分类 -  python

摘要:一、安装 1、运行安装程序,直接使用默认选项安装 2、注意安装路径中不能带中文,否则会git bash失败(如果失败,建议卸载重装) 3、配置两个环境变量 一个是git/cmd 一个是git/bin 二、命令 1、git clone 带用户名和密码 git clone https://usernam 阅读全文
posted @ 2025-04-09 17:54 hushuer
摘要:A=[0,1,2,3,4,5,6,7,8,9] A[:6:-1] 答案是[9,8,7] A[1:6:-1] 答案是[] 因为是步长从1开始-1,为0,而1:6,后面的数值越来越大,所以在1:6这个范围取不到值。 https://blog.51cto.com/u_16175525/13231128 阅读全文
posted @ 2025-03-13 17:43 hushuer
摘要:a=0b=1while b<100: a,b=b,a+b print(a) 结果: 1123581321345589 阅读全文
posted @ 2025-03-09 23:34 hushuer
摘要:逻辑一,ramdom.choise,随机从列表汉字中取值 逻辑二,使用ramdom.ramdint随机取unicode的值,再转为汉字 import random def generate_random_chinese(num): chinese_chars = [] for i in range( 阅读全文
posted @ 2025-03-09 13:49 hushuer
摘要:lambda:英文含义是,希腊字母表第11个字母 https://baijiahao.baidu.com/s?id=1781168343754714555&wfr=spider&for=pc 阅读全文
posted @ 2025-03-09 11:56 hushuer
摘要:比单纯用+提升很多效率 1、可以将列表拼接为带不同间隔符的字符串 2、*对于列表中带多个子列表的数据,可以使用两次.join,将列表彻底转为字符串 3、可以将字符串打散为单个字符,再加上拼接符拼接(有点把字符串看成字符组成的列表的意思) 4、只能拼接str类型,遇到数值需要先转为str类型,再拼接 阅读全文
posted @ 2025-03-09 11:27 hushuer
摘要:基本方法: 1、菜鸟教程 https://www.runoob.com/regexp/regexp-syntax.html 2、调用方法 https://blog.csdn.net/JJJJJJJerry/article/details/119488529 例子:匹配日期 https://blog. 阅读全文
posted @ 2025-03-08 12:12 hushuer
摘要:写法一: 1 paths=['D:\lser\local file1.txt(abcd)file2.txt(wxsd)file3.txt(qqw)','E:\path\jdk file2.txt(abcd)file5.txt(vv)','C:\duafile\dublock\dufell file4 阅读全文
posted @ 2025-03-01 13:19 hushuer
摘要:一、线程、进程的区别 https://www.zhihu.com/question/25532384 二、实际使用场景 登录3个用户,然后用这3个用户的session,进行10个进程,或者10个线程的操作(因为登录后没有退出登录,也没有被其他地方登录挤掉账号,所以session在一段时间内有效。且当 阅读全文
posted @ 2024-11-14 17:32 hushuer
摘要:【参考】 方法一参考链接如下,直接获取返回的cookie失败,拿到的cookies是空。(因为登录的url返回用f12看着是空的,用Charles才能看到,进行了重定向,返回了重定向的url) https://baijiahao.baidu.com/s?id=1781328761925882355& 阅读全文
posted @ 2024-08-29 17:57 hushuer
摘要:【场景】 测试使用图片验证码登录 接口返回的是图片的base64编码,我们需要 1、将base64编码转为图片 2、去识别图片中的验证码,然后再拿验证码去做后续的图片验证码登录测试 【参考链接】 https://blog.51cto.com/u_16213316/10678659 https://w 阅读全文
posted @ 2024-07-26 17:42 hushuer
摘要:1、从sql读取需要的内容,作为接口的请求参数的一部分,生成请求的body,再去请求接口 1 import requests 2 import pymysql 3 import json 4 5 6 conn = pymysql.connect(host="172.16.11.118", port= 阅读全文
posted @ 2024-07-17 14:29 hushuer
摘要:参考: https://www.php.cn/faq/630018.html https://blog.csdn.net/weixin_42575020/article/details/128850513?utm_medium=distribute.pc_relevant.none-task-blo 阅读全文
posted @ 2024-01-12 16:01 hushuer
摘要:一、网上的参考 https://www.begtut.com/python/ref-requests-delete.html 二、我的写法 接口长这样 参数是以json传入: a={'id':'xxxxxxxxxxxx','xx':'xxxxxxxx','xx':'xxxxxxxx','xx':'x 阅读全文
posted @ 2023-05-09 17:18 hushuer
摘要:https://blog.csdn.net/qq_41985134/article/details/122956104 阅读全文
posted @ 2023-03-30 15:05 hushuer
摘要:需求:希望一段时间内,每一天都生成随机的开始时间和结束时间 问题: 使用pandas生成了每一天,然后没有想到怎么用随机的时间去做加减 解决:生成随机的时分秒之后,转为str,再和pandas生成的每一天的str拼接起来 阅读全文
posted @ 2023-03-30 11:50 hushuer
摘要:strftime: 将给定格式的日期时间对象转换为字符串。日期时间对象=>字符串,控制输出格式 strptime:将字符串解析为给定格式的日期时间对象。字符串=>日期时间对象,解析字符串 一般进行接口请求时,或者将数据写入数据库时,传入的时间参数均为字符串格式,所以需要strftime。 如果是使用 阅读全文
posted @ 2023-01-03 11:59 hushuer
摘要:1、json.dumps(),json.loads() json.dumps() 将python对象(dict)编码成Json字符串(str) json.loads() 将Json字符串(str)解码成python对象(dict) 一般构造接口数据本身时,该数据本身为dict格式,需要使用json. 阅读全文
posted @ 2023-01-03 11:20 hushuer
摘要:参考: https://www.cnblogs.com/liangmingshen/p/8909376.html 1.random.random() #用于生成一个0到1的 随机浮点数:0<= n < 1.0 1 import random 2 a = random.random() 3 print 阅读全文
posted @ 2022-12-28 10:40 hushuer
摘要:(1)创建mqtt连接 参考https://www.jianshu.com/p/06d23de47aed 文中写的发布消息代码如下: 文件名:mypub.py #!/usr/bin/env python #coding:utf-8 import time import json import psu 阅读全文
posted @ 2022-12-27 15:44 hushuer