我正在研究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) 我正在阅读有关可变参数的模板,我遇到了这个例子.该书提到,为了结束递归过程,使用了该函数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) 我想获得在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)