随笔分类 -  Python / 代码片段

摘要:sshClient = paramiko.SSHClient() ssh_cli = sshClient ssh_cli.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh_cli.connect(hostname=netone_ip, 阅读全文
posted @ 2024-12-25 16:28 你说夕阳很美 阅读(64) 评论(0) 推荐(0) 编辑
摘要:import re # 正则表达式匹配 IP 地址 ip_pattern = r'(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[0 阅读全文
posted @ 2024-12-04 21:11 你说夕阳很美 阅读(56) 评论(0) 推荐(0) 编辑
摘要:python将一维列表变二维 - CSDN文库 # 将一维列表转为二维列表,每行元素个数为n n = 3 one_dim_list = [1, 2, 3, 4, 5, 6, 7, 8, 9] two_dim_list = [one_dim_list[i:i+n] for i in range(0, 阅读全文
posted @ 2024-11-28 10:02 你说夕阳很美 阅读(10) 评论(0) 推荐(0) 编辑
摘要:7e713d354f0fa6 Content-Disposition: form-data; name="username" log_username 7e713d354f0fa6 Content-Disposition: form-data; name="password" log_pwd 7e7 阅读全文
posted @ 2024-10-18 10:16 你说夕阳很美 阅读(10) 评论(0) 推荐(0) 编辑
摘要:Python中的枚举数据类型(Enum)_python enum-CSDN博客 默认属性name和value from enum import Enum class Weekday(Enum): monday = 1 tuesday = 2 wednesday = 3 thirsday = 4 fr 阅读全文
posted @ 2024-10-11 16:04 你说夕阳很美 阅读(17) 评论(0) 推荐(0) 编辑
摘要:from pathlib import Path # 创建一个Path对象表示目录 base_directory = Path('C:/path/to/your/directory') # 使用/运算符来拼接子目录和文件名 file_path = base_directory / 'subdirec 阅读全文
posted @ 2024-06-27 17:23 你说夕阳很美 阅读(97) 评论(0) 推荐(0) 编辑
摘要:from pathlib import Path def find_latest_modified_file(directory): latest_file = None latest_file_time = 0 # 遍历目录中的所有文件 for file in directory.iterdir( 阅读全文
posted @ 2024-06-27 17:21 你说夕阳很美 阅读(87) 评论(0) 推荐(0) 编辑
摘要:需求是MeterSphere测试计划状态是已完成/已结束,测试进度不是100%。 排查发现是test_plan_test_case表中已取消关联的用例算在了测试用例总数导致的 所以做了一个命令行工具方便其他人处理该问题 python click库常用函数详解_click函数-CSDN博客 pytho 阅读全文
posted @ 2024-04-10 09:54 你说夕阳很美 阅读(30) 评论(0) 推荐(0) 编辑
摘要:# 方法1 eval # 方法2 ast.literal_eval() >>> string_list = "[1, 2, 3, 4, 5]" >>> print(type(eval(string_list))) <class 'list'> >>> >>> print(type(string_li 阅读全文
posted @ 2024-03-26 12:00 你说夕阳很美 阅读(10) 评论(0) 推荐(0) 编辑
摘要:# 方法1 import time # 获取当前时间戳 timestamp = int(time.time()) # 打印时间戳 print(f"当前时间戳:{timestamp}") # 当前时间戳:1711418156 # 方法2 import datetime # 创建一个示例的日期时间对象 阅读全文
posted @ 2024-03-26 11:04 你说夕阳很美 阅读(1203) 评论(0) 推荐(0) 编辑
摘要:def timestamp_difference_to_dhms(timestamp1, timestamp2): # 将时间戳转换为 datetime 对象 # # 13位时间戳会报错 if len(str(timestamp1)) == 13: timestamp1 = timestamp1 / 阅读全文
posted @ 2024-03-22 14:14 你说夕阳很美 阅读(101) 评论(0) 推荐(0) 编辑
摘要:在Python中,可以使用html2text库将HTML内容转换成纯文本,保留一定的格式。首先需要安装这个库: pip install html2text 然后使用它的html2text函数将HTML转换为Markdown格式的文本: import html2text # 示例HTML内容 html 阅读全文
posted @ 2024-03-22 10:13 你说夕阳很美 阅读(181) 评论(0) 推荐(0) 编辑
摘要:File Upload - web-api (seafile.com) 060-轻量级基于curl的seafile上传脚本 - 掘金 (juejin.cn) 在线curl命令转代码 (lddgo.net) from datetime import datetime import requests i 阅读全文
posted @ 2024-03-01 17:41 你说夕阳很美 阅读(21) 评论(0) 推荐(0) 编辑
摘要:import paramiko import time def monitor_linux_log(linux_ip, username, password, log_file): client = paramiko.SSHClient() client.set_missing_host_key_p 阅读全文
posted @ 2024-01-30 16:48 你说夕阳很美 阅读(30) 评论(0) 推荐(0) 编辑
摘要:# 获取今天的开始和结束时间戳 def get_today_timestamp_interval(): today = datetime.now() # 获取昨天的开始时间(00:00:00) start_of_day = today.replace(hour=0, minute=0, second 阅读全文
posted @ 2024-01-26 17:10 你说夕阳很美 阅读(11) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2024-01-26 17:02 你说夕阳很美 阅读(18) 评论(0) 推荐(0) 编辑
摘要:发送消息内容结构 - 服务端 API - 开发文档 - 飞书开放平台 卡片 JSON 结构 - 开发指南 - 开发文档 - 飞书开放平台 组件概述 - 开发指南 - 开发文档 - 飞书开放平台 富文本(Markdown) - 开发指南 - 开发文档 - 飞书开放平台 飞书开发学习笔记(七)-添加机器 阅读全文
posted @ 2024-01-23 09:46 你说夕阳很美 阅读(329) 评论(0) 推荐(0) 编辑
摘要:本例是:本周三前一个礼拜的日期范围,包括今天 import datetime current_date = datetime.date.today() # days=2 代表礼拜三 # # current_date - datetime.timedelta(days=current_date.wee 阅读全文
posted @ 2023-12-21 15:08 你说夕阳很美 阅读(25) 评论(0) 推荐(0) 编辑
摘要:使用groups() import re text = "Hello, my name is John Doe. I live in New York." match = re.search(r'\b(\w+)\b', text) if match: print("Match found: ", m 阅读全文
posted @ 2023-10-31 16:29 你说夕阳很美 阅读(32) 评论(0) 推荐(0) 编辑
摘要:python3.7 获取网络时间_python 获取网络时间-CSDN博客 2024-6-7 14:23:18,get_beijing_time()获取时间有问题;推荐使用从ntp获取另外从api.m.taobao.com/rest/api3.do?api=mtop.common.getTimest 阅读全文
posted @ 2023-10-31 10:21 你说夕阳很美 阅读(463) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示