import os
import cv2
path = 'C:\Users\rishi\Documents\Sudoky-Solver\Sudoky-Solver\test'
list = os.listdir(path)
def newest(path):
files = os.listdir(path)
paths = [os.path.join(path, basename) for basename in files]
return max(paths, key=os.path.getctime)
while True:
list2 = os.listdir(path)
if list2 != list:
imgpath = newest(path)
img = cv2.imread(str(imgpath).replace('\', '/'))
print(type(img))
list = list2
当我运行代码时,代码会给出错误
输出:
<class 'NoneType'>
您将得到<类"非类型">只有当路径不正确时。此外,有时您必须将图像路径作为原始输入(r‘D:……’(传递,因为路径中可能有/t左右。只需打印路径并首先检查即可。:(