- 二维list初始化
>>> import numpy as np
>>> k=[[None for i in range(4)] for j in range(3)]
>>> np.shape(k)
(3, 4)
- cv2读取png报错(libpng error: Read Error); cv2.imdecode解析png报错(libpng error: PNG input buffer is incomplete)
import cv2, random
import os
import numpy as np
from PIL import Image
from PIL import ImageFile
import imghdr
ImageFile.LOAD_TRUNCATED_IMAGES = True
if imghdr.what(name) == "png":
Image.open(name).convert("RGB").save(name)
img = cv2.imread(name)
img = np.array(Image.open(name))
- 变量类型判断
if obj is None:
pass
elif not isinstance(obj, (list, tuple,dict)):
pass
dictMerged2 = dict( dict1, **dict2 )
参考文献: