随笔分类 - Python
摘要:``` import csv def parseCSVFileStr(data): """ 将csv转换为 [{},{},{},{},{},{},] 形式的列表 """ titleFlag = 0 ldata = [] ltitle = [] data = data.replace('"', '')
阅读全文
摘要:常用 ``` # float 整数位为秒 time.time() # struct_time time.localtime() # string time.ctime() # string time.asctime() ``` 转换 ``` # struct_time time.localtime(
阅读全文
摘要:初始化webdriver ``` opts = webdriver.chrome.options.Options() # 无头模式 opts.add_argument("--headless") opts.add_argument("--disable-gpu") # 驱动地址 driver_pat
阅读全文
摘要:# 指定版本的opencv pip install opencv_contrib-python==3.4.3.18 # pywin32 [win32gui,win32api,win32con...] pip install pypiwin32
阅读全文
摘要:pip install pycryptodome==3.14.1 import base64 # AES CBC加密 from Crypto.Cipher import AES BLOCK_SIZE = 16 # Bytes vi = '0102030405060708' def pad(s): r
阅读全文
摘要:``` import tempfile _file_data = bytes('文件数据') _temp_file = tempfile.NamedTemporaryFile() _temp_file.write(_file_data) # 保存 _temp_file.flush() # 指针指向文
阅读全文
摘要:operators = { 'exact': '= %s', 'iexact': 'LIKE %s', 'contains': 'LIKE BINARY %s', 'icontains': 'LIKE %s', 'regex': 'REGEXP BINARY %s', 'iregex': 'REGE
阅读全文
摘要:替换源 ``` # 显示所有通道 conda config --show channels # 删除所有通道 conda config --remove-key channels # 清华镜像使用帮助 https://mirror.tuna.tsinghua.edu.cn/help/anaconda
阅读全文
摘要:from tkinter import filedialog import os import cv2 def saveImage(video_name: str, interval: int = 60, start: int = 0, end: int = -1, output_dir: str
阅读全文
摘要:常用 from tkinter import filedialog filedialog.askopenfilename(***options) filedialog.askopenfilenames(**options) filedialog.asksaveasfile(**options) fi
阅读全文
摘要:Python打包exe的王炸-Nuitka - 知乎 https://zhuanlan.zhihu.com/p/133303836 1.安装gcc 2.打包测试 nuitka 你的.py 3.打包 nuitka --mingw64 --standalone --show-progress --sho
阅读全文
摘要:``` # 对象类型 type(object) # 对象属性及方法 dir(object) # 对象属性和属性值的字典 vars(object) # 方法的参数名 function.__code__.co_varnames # 方法的参数个数 function.__code__.co_argcoun
阅读全文
摘要:说明: 为信号连接槽函数, 在信号激发时实现对槽函数的调用. 作用: 一个信号可以绑定多个槽函数, 实现一对多的激发效果. 信号也可以连接其他的信号. 跨线程时, 必须使用信号进行参数传递. from PyQt5.QtCore import QObject, pyqtSignal, pyqtSlot
阅读全文
摘要:from PIL import Image path = './test.png' # 加载图片 im = Image.open(path) # 显示图片 im.show() # 图片大小 w, h = im.size x, y = 0, 0 box = (x*w, y*h, (x+1)*w, (y
阅读全文
摘要:path = './test/' # 创建路径 def mkdir(path): if not os.path.exists(path): os.makedirs(path) # 查文件列表 os.listdir(path) # 判断是否为文件夹 os.path.isdir(path) # 判断是否
阅读全文
摘要:图片保存工具 # 图片张数 N = 16 # 通道数 C = 3 # 高度 H = 64 # 宽度 W = 32 image = torch.rand(N,C,H,W) # 路径 path = './' save_image(image, path)
阅读全文
摘要:# 原始数据 test = [1, 2, 3, 4, 5, 6, 7, 8, 9] # 正向切片 print(test[2:4]) [3, 4] # 反向切片 print(test[-4:-2]) [6, 7] # 从头切片 print(test[:-2]) [1, 2, 3, 4, 5, 6, 7
阅读全文
摘要:## pydirectinput ``` # 安装 pip install pydirectinput ``` ``` # 使用 import pydirectinput pydirectinput.moveTo(100, 150) # 移动鼠标至坐标100,150 pydirectinput.cl
阅读全文
摘要:# 修改默认源 pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple # 临时修改源 pip install django -i https://pypi.tuna.tsinghua.edu.cn/simpl
阅读全文
摘要:示例 # excel库xlsx import openpyxl import xlrd import tkinter.filedialog as filedialog import os def parseXLSX(filename, sheetNum=1): """ 解析excel文件, 并返回列
阅读全文

浙公网安备 33010602011771号