# -*- coding: utf-8 -*- import cv2 # 读取图片 img = cv2.imread('phone.png') # h、w为想要截取的图片大小 h = 35 w = 170 x = 500 y = 425 cropImg = img[(y):(y + h), (x):(x + w)] cv2.imwrite('test.png', cropImg)