小编rah*_*agi的帖子

正则表达式与C++ regex_match无法正常工作

我正在研究c ++ 11中的正则表达式,这个正则表达式搜索返回false.有谁知道我在做错了什么?.我知道.*除了换行符之外,它代表任意数量的字符.

所以我期待regex_match()返回true并将输出"找到".然而,输出结果是"未找到".

#include<regex>
#include<iostream>

using namespace std;

int main()
{
    bool found = regex_match("<html>",regex("h.*l"));// works for "<.*>"
    cout<<(found?"found":"not found");
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

c++ regex c++11

7
推荐指数
1
解决办法
1114
查看次数

无法理解c ++中的可变参数模板

我正在阅读有关可变参数的模板,我遇到了这个例子.该书提到,为了结束递归过程,使用了该函数print().我真的无法理解它的用途.为什么作者使用这个空print()函数?

void print () // can't get why this function is used
{
}

template <typename T, typename... Types>
void print (const T& firstArg, const Types&... args)
{
    std::cout << firstArg << std::endl; // print first argument
    print(args...); // call print() for remaining arguments
}
Run Code Online (Sandbox Code Playgroud)

c++ templates variadic-templates c++11

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

在tkinter(Python)中获取在画布上绘制的项目的填充色或任何其他属性

我想获得在tkinter的画布中绘制的项目的填充颜色或其他任何属性。

  def createWidgets(self):
    self.canvas_1= tk.Canvas(self, bg='#FAFAFA',selectforeground='#BBDEFB');
    i=self.canvas_1.create_rectangle((self.canvas_1.winfo_reqwidth()/2)+100,
                                   (self.canvas_1.winfo_reqheight()/2)+50,
                                   (self.canvas_1.winfo_reqwidth()/2)+150,
                                   (self.canvas_1.winfo_reqheight()/2)+100, 
                                    fill='#FF4081',width=0)
    self.canvas_1.grid();
    color=               #want to access the fill color of item i using some getter functions.
Run Code Online (Sandbox Code Playgroud)

python canvas tkinter

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

标签 统计

c++ ×2

c++11 ×2

canvas ×1

python ×1

regex ×1

templates ×1

tkinter ×1

variadic-templates ×1