随笔分类 - python
摘要:from gmssl import sm2,sm4 import base64 class SM4(): def __init__(self, key, iv="12345678"): self.key = key self.iv = iv def encrypt(self,text): """ 加
阅读全文
摘要:创建单个进程示例: from multiprocessing import Processimport time def add(a, b): print("starting to job") print(a + b) time.sleep(1) print("stoping to job") if
阅读全文
摘要:import gevent from gevent import monkey monkey.patch_all() from minio import Minio import time, random import uuid def get_client(): """ 连接minio :retu
阅读全文
摘要:from minio import Minio from multiprocessing import Process import time def upload_file(): # 创建minio客户端 client = Minio(endpoint="xxx.xxx.xxx.xxx:xxx",
阅读全文
摘要:from minio import Minio file_name = '3e09ca66d9444906935b0171e26891f1.mp4' file_path = r'E:\集成资料\视频素材' barrel = "testdata" def upload_file(): # 创建mini
阅读全文
摘要:server: 当调用http://xxx.xxx.xxx.xxx:4500/push时就会触发get_push函数 from bottle import run, route, request import logging import time import os filename = str(
阅读全文
摘要:一.在Linux中搭建mqtt服务 环境:Linux 版本Ubuntu 18.04.1 LTS 1.进入https://www.emqx.com/zh/try?product=broker下载开源版本 EMQX 此处选择zip格式 2.下载后将emqx-4.4.14-otp24.3.4.2-1-ub
阅读全文
摘要:1.xmind文件模板如下所示(最后一个子级为预置条件) 2.excel用例模板 3.获取xmind文件数据并转成字典形式 from xmindparser import xmind_to_dict #xmind_to_dict可读取xmind文件并转成字典形式展示 def get_xmind(fi
阅读全文
摘要:源码: import modbus_tk from modbus_tk import modbus_tcp import modbus_tk.defines as cst PORT = 'com1' def main(): """main""" logger = modbus_tk.utils.cr
阅读全文
摘要:源码: def output(self, level, message): fh = logging.FileHandler(self.logpath, mode='a', encoding='utf-8') fh.setLevel(logging.DEBUG) fh.setFormatter(se
阅读全文
摘要:代码: sql = "select * from appelementinfo" coon = pymysql.connect(user='root', password='', db='autoplatform', port='3306', host='127.0.0.1', charset='u
阅读全文
摘要:import schedule import time def job(): print("定时通报...") # 定义一个叫job的函数,函数的功能是打印'定时通报...' schedule.every(2).seconds.do(job) # 部署每2s执行一次job()函数的任务 schedu
阅读全文
摘要:import smtplib from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart from email.header import Header def send_email(send
阅读全文
摘要:环境准备: 安装 myqr, pip install myqr 参数解析: myqr.run( words='teter', # 扫描二维码后,显示的内容,或是跳转的链接 version=5, # 设置容错率,int,控制边长,范围1到40, level='H', # 控制纠错水平,范围是L、M、Q
阅读全文
摘要:1.integerbox()函数:只可输入整数的输入框,默认输入范围为0-99 integerbox(msg="", title=" ", default=None,lowerbound=0, upperbound=99, image=None, root=None) 参数介绍: msg: 输入框描
阅读全文
摘要:游戏:随机生成个谜底,每轮有3次机会,猜对了结束本轮游戏,猜错了提示猜大了还是猜小了,并显示剩余次数,3次用完后本轮字谜游戏结束,可重新开始猜字谜,也可结束游戏 # 使用 easygui 实现猜字谜游戏 import easygui as g import sys import random whi
阅读全文
摘要:在python中,至少有两类错误,一种是程序语法错误,一种是程序异常。 所谓的语法错误是指你未按规定格式书写导致的错误,如:定义函数时,括号后面要紧跟英文冒号,若缺失则不能识别与运行,并抛出 SyntaxError: invalid syntax错误 def exceptions() print("
阅读全文
摘要:举个例子: str1 = 'sunlightn' f = str1.rfind("n", __start=1, __end=2) print(f) 以上代码运行后出现: "D:\Program Files\Python\Python37-32\python.exe" D:/demo/str_1.py
阅读全文
摘要:在python中,字符串是最常用的数据类型,通常由单引号(' ')、双引号(" ")、三重引号(''' ''',""" """)引起来。 # 字符串的创建 str1 = "hello world" str2 = 'sunlight' str3 = '''On a new day, the sun r
阅读全文
摘要:import os import xlrd PATH = lambda p: os.path.abspath( os.path.join(os.path.dirname(__file__), p) ) class ExcelData: def __init__(self, file, sheet="
阅读全文