__python
python
舞小潮
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
创建定时任务
schedule.every().wednesday.at("13:15").do(task) # 每周三13:15。schedule.every().day.at("10:30").do(task) # 每天十点半。schedule.every(5).to(10).days.do(task) # 每隔5到10天。schedule.every(10).seconds.do(task) # 每10秒一次。schedule.every(10).minutes.do(task) # 10分钟一次。原创 2023-06-08 11:35:21 · 717 阅读 · 0 评论 -
判断是否存在目录,没有就创建
def is_path_exist(self, path): if not os.path.exists(path): os.mkdir(path)原创 2023-06-08 11:16:07 · 213 阅读 · 0 评论 -
**kwargs的用法
def test(**kwargs): for key, value in kwargs.items(): print(f'{key}:{value}') test(a=1, b=2)原创 2023-05-30 10:30:00 · 96 阅读 · 0 评论 -
python 的字符串转为字典
python的字符串转为字典原创 2022-08-03 11:39:43 · 218 阅读 · 0 评论 -
python调用linux命令并读取返回结果
re = os.popen(cmd).read() #读取整个返回结果为strre = os.popen(cmd).readline() #读取第一行结果为strre = os.popen(cmd).readlines() #按行读取整个返回结果为列表cmd = "http://test:test%400%s" % name #错误,前面不是变量的%要多加一个%cmd = "http://test:test%%400%s" % name #正确...原创 2021-08-09 14:35:00 · 757 阅读 · 0 评论 -
python读取excle的日期或时间,并处理
python读取excel中单元格的内容返回的有5种类型,即上面例子中的ctype:ctype: 0 empty,1 string, 2 number, 3 date, 4 boolean, 5 errorimport xlrdfrom xlrd import xldate_as_tuplewb = xlrd.open_workbook('data31.xlsx')sh = wb.sheet_by_name('sheet1')for i in range(1, 7): .原创 2021-07-20 15:48:48 · 6013 阅读 · 0 评论 -
logging的使用python3
#以时间命名输出日志t = str(time.strftime("%Y%m%d_%H%M", time.localtime()))filename = 'log_%s.txt' % tlogging.basicConfig(level=logging.DEBUG,filename=filename,filemode='w', format='%(asctime)s - %(f...原创 2021-07-19 11:56:37 · 369 阅读 · 0 评论 -
python常见应用场景和题目
#输入一个字符,判断是否等于,不是重新输入while 1: exe_type = input("输入0仅导出文件,输入99直接删除:") if exe_type == '0': self.del_cvm_list_file(list_a) break elif exe_type == '99': self.del_vm_list_file(list_a) self.del_vm_bianpai(list_a)...原创 2021-03-09 16:31:47 · 288 阅读 · 0 评论 -
postman的pm对象断言
pm 对象还提供了测试相关功能:pm.test 函数用来生成一个测试,可以输入测试标题,并加入各种断言。断言全部成功则测试成功,某一个断言失败则测试失败;一个请求可以添加多个测试函数。 pm.expect 函数,用来生成各种断言; pm.response 对象中也提供了很多内置的断言语句。pm.testpm.test(testName:String, specFunction:Function):Function:这个函数已经在我们之前的文章中出现过很多次了,只是那时候不需要大家深入了解,转载 2021-03-08 10:41:28 · 3375 阅读 · 0 评论 -
py+requests接口
断言:assert res_login4.status_code == 200, "状态码不为200"assert res_login4.json()["result"] == 1, "结果不为1"assert res_login4.json()["data"] is not None, "data结果为空"assert res_login4.json()["data"]["noDefaultOps"] is True, "结果为真"#pytest框架有自带断言方法?#postman断言原创 2021-03-08 10:19:47 · 138 阅读 · 0 评论 -
pycharm常用功能
ctrl+shift+'+' //+打开所有方法,-收缩ctrl+B //跳到声明处原创 2020-07-31 15:51:39 · 722 阅读 · 0 评论 -
监控某个目录下日志文件,并且筛选关键字生成过滤日志
import loggingimport osimport threadingimport time'''****************By WuXuechao 20200719*******************功能:监控某个目录下日志文件,并且筛选关键字生成过滤日志,保存当前目录test文件夹下变量说明:log_path:日志所在目录log_file:日志文件(含后缀)keywords:搜索关键字用**隔开****************By WuXuechao 202007.原创 2020-07-19 19:32:30 · 230 阅读 · 0 评论 -
python环境
chromedriver下载地址:http://chromedriver.storage.googleapis.com/index.html下载对应版本的chromedriver,放在python根目录下面即可,不用配置path原创 2020-06-14 23:22:23 · 141 阅读 · 0 评论 -
将python工程打包成exe程序
pip install pyinstaller安装成功后,pyinstaller -F +主程序.py -p +需要import的自己编写的模块的路径生成两个目录。dist里面生成exe文件注意:配置文件的存在路径,不然exe运行不起来原创 2020-06-13 23:53:50 · 178 阅读 · 0 评论 -
python易错
print(5/2)print(5//2)print(5.0//2)print(5%2)print(5**2)循环:range(start, stop[, step])start: 计数从 start 开始。默认是从 0 开始。例如range(5)等价于range(0, 5); stop: 计数到 stop 结束,但不包括 stop。例如:range(0, 5) 是[0, 1, 2, 3, 4]没有5 step:步长,默认为1。例如:range(0, 5) 等价于 .原创 2020-06-13 23:40:11 · 109 阅读 · 0 评论
分享