小编Roy*_*Dan的帖子

比较包含负字符的字符串时出现令人惊讶的结果

#include "stdafx.h"
#include "iostream"
#include "string"

using namespace std;

void main()
{
    string a = "a";
    string b(1, -70); /*constructor, create a string having 1 character that its value is equal to -70*/
    cout << (b > a ? b : a);
}

//output on screen: b was printed, not a (!)
Run Code Online (Sandbox Code Playgroud)

虽然b的值小于a的值,为什么b>a?我该如何纠正这种情况?

c++ string comparison stdstring

5
推荐指数
1
解决办法
770
查看次数

matplotlib绘制在显示图像时循环缓慢

我正在做的是在无限循环中向一个图形交替显示2个图像,直到用户点击窗口关闭它.

#import things
import matplotlib
matplotlib.use("TkAgg")
import matplotlib.pyplot as plt
import cv2
import time

#turn on interactive mode for pyplot
plt.ion()

quit_frame = False

#load the first image
img = cv2.imread("C:\Users\al\Desktop\Image1.jpg")
#make the second image from the first one
imggray = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)

def onclick(event):
    global quit_frame
    quit_frame = not quit_frame

fig = plt.figure()
ax = plt.gca()
fig.canvas.mpl_connect('button_press_event', onclick)

i = 0

while quit_frame is False:
    if i % 2 == 0: #if i is even, show the first image …
Run Code Online (Sandbox Code Playgroud)

python matplotlib

2
推荐指数
1
解决办法
1792
查看次数

标签 统计

c++ ×1

comparison ×1

matplotlib ×1

python ×1

stdstring ×1

string ×1