我的阈值图像,然后我想显示图像使用plt.imshow公司. 你知道吗
ret, threshold = cv2.threshold(gray, 100, 255, cv2.THRESH_BINARY)
plt.imshow(threshold)
plt.show()
但是我得到了错误
> It does not make sense to draw an image when [NSGraphicsContext
> `currentContext] is nil. This is a programming error. Break on void
> _NSWarnForDrawingImageWithNoCurrentContext(void) to debug. This will be logged only once. This may break in the future.`
是的,它创建了第10个字符串
请注意,这段代码本身只需要创建5个字符串——如果您在同一个JVM中多次运行它,每次调用它时它都会创建5个新字符串。字符串文本不会在每次代码运行时创建新字符串。(例如,每次
"spring "
都会重复使用相同的字符串对象。)您给出的代码中有10个字符串:
s1 + "summer"
、s1.concat("fall ")
、s1 + winter
(带复合赋值)和s1 + " " + s2
李>正如我刚才所评论的,代码中出现的字符串文本并不总是包含一个单独的字符串。例如,考虑:
您可能认为这涉及三个字符串对象——一个用于每个文本,一个用于连接。事实上,它只涉及一个,因为编译器在编译时执行串联,所以代码有效:
相关问题 更多 >
编程相关推荐