随笔分类 - Python
摘要:from pynput import keyboard # 按下后执行 def on_press(key): try: if key == keyboard.KeyCode.from_char('enter'): pass elif key == keyboard.Key.left: print("
阅读全文
摘要:def window_capture_beat(hwnd,stayx:int,endx:int,stay:int,endy:int): hwndDC = win32gui.GetWindowDC(hwnd) mfcDC = win32ui.CreateDCFromHandle(hwndDC) sav
阅读全文
摘要:import time import pyautogui def rgb2hex(r, g, b): return '#{:02x}{:02x}{:02x}'.format(r, g, b) try: width, height = pyautogui.size() while True: time
阅读全文
摘要:#实时获取当前活动窗口的句柄及标题并输出至控制台 import win32gui while True: time.sleep(1) now_hwnd = win32gui.GetForegroundWindow() now_hwnd_title = win32gui.GetWindowText(n
阅读全文
摘要:图片来源:https://blog.csdn.net/caohongxing/article/details/120407381 实用实例: 1、截取图片 img = cv2.imread("img_path") img = img[y1:y2, x1:x2] 2、检查某个像素点的RGB img =
阅读全文
摘要:1 #对后台窗口截图 2 import win32gui, win32ui, win32con 3 import cv2 4 import numpy as np 5 6 #获取后台窗口的句柄,注意后台窗口不能最小化 7 hWnd = win32gui.FindWindow("NotePad",No
阅读全文
摘要:转载自https://www.cnblogs.com/codingmylife/archive/2010/06/06/1752807.html 1.性能 Py3.0运行 pystone benchmark的速度比Py2.5慢30%。Guido认为Py3.0有极大的优化空间,在字符串和整形操作上可 以
阅读全文
摘要:装饰器本质上是一个 Python 函数或类,它可以让其他函数或类在不需要做任何代码修改的前提下增加额外功能,装饰器的返回值也是一个函数/类对象。它经常用于有切面需求的场景,比如:插入日志、性能测试、事务处理、缓存、权限校验等场景,装饰器是解决这类问题的绝佳设计。有了装饰器,我们就可以抽离出大量与函数
阅读全文
摘要:1. 安装依赖环境 # yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel
阅读全文