Python中 L = [1,2,3,4,5,6,7] 从L中取出3,4,5,6的方法有多少种

L = [1,2,3,4,5,6,7]
从L中取出3,4,5,6的方法有多少种

我知道L[2:6]能取出,还有吗

PNG图像从我的iPhone到我的MacBook通过TCP。 MacBook的代码是从怎样的形象与OpenCV的转换? PNG格式被选中它们是有效的,但其他格式可以 我写了一个测试程序,从文件中读取的rawImage,但不知道如何将它转化成:# Read rawImage from a file, but in reality will have it from TCPServer
f = open('frame.png', "rb")
rawImage = f.read()
f.close()

# Not sure how to convert rawImage
npImage = np.array(rawImage)
matImage = cv2.imdecode(rawImage, 1)

#show it
cv.NamedWindow('display')
cv.MoveWindow('display', 10, 10)
cv.ShowImage('display', matImage)
cv. WaitKey(0)

1. 另一种方式, 也是在阅读一个实际的文件的情况下,这将适用于一个unicode路径(在Windows上进行测试)with open(image_full_path, 'rb') as img_stream:
file_bytes = numpy.asarray(bytearray(img_stream.read()), dtype=numpy.uint8)
img_data_ndarray = cv2.imdecode(file_bytes, cv2.CV_LOAD_IMAGE_UNCHANGED)
img_data_cvmat = cv.fromarray(img_data_ndarray) # convert to old cvmat if needed
温馨提示:答案为网友推荐,仅供参考
第1个回答  2018-02-14
36
第2个回答  2018-02-14
36种
相似回答