html:
<td>some key
</td>
Run Code Online (Sandbox Code Playgroud)
找不到正则表达式:
soup.find(text='some key')
Run Code Online (Sandbox Code Playgroud)
没有
找到正则表达式
soup.find(text=re.compile('some key'))
Run Code Online (Sandbox Code Playgroud)
返回了td节点.
有人会指出这两种方法之间的区别吗?"some key"是没有特殊字符的文字字符串.我注意到</td>在下一行出现的"某个键"末尾有一个回车符.
谢谢.
此问题与以下转载的代码段有关:
struct A {
A():b(0) { }
A(const A&, int b = 0):b(b) { }
int b;
};
int main() {
A a;
const A& a1 = { a };
const A& a2 = { a, 1 };
a.b = 2;
std::cout << a1.b << a2.b << std::endl;
}
Run Code Online (Sandbox Code Playgroud)
分配a1的右侧可以是构造中的单个值或构造的参数列表.标准中是否有任何指定哪种解释优先?对于a2,它是一个临时A的结构,如果我没有误解,它的地址被分配给a2.
顺便说一句,在Coliru中用clang ++编译这段代码就产生了输出21. gcc ++ - 4.8输出01.
有什么区别
typedef void (&FunctionTypeR)();
Run Code Online (Sandbox Code Playgroud)
VS
typedef void (FunctionType)();
Run Code Online (Sandbox Code Playgroud)
第二个也是功能的参考吗?是FunctionTypeR相当于FunctionType&作为参数的类型时?
对于
void foo(FunctionType bar)
Run Code Online (Sandbox Code Playgroud)
在调用foo时,运行时是否复制了参数栏(函数)?
可移动转换运算符的语法是什么?
我有一个包装的包装器obj,它有一个obj转换运算符:
class wrap {
public:
operator obj() { ... }
private:
obj data_;
};
Run Code Online (Sandbox Code Playgroud)
如何确定是否data_应复制或移动?
我应该如何为部分特化初始化静态变量?
template <bool A=true, bool B=false>
struct from {
const static std::string value;
};
// no specialization - works
template <bool A, bool B>
const std::string from<A, B>::value = "";
// partial specialization - does not compile -
// Error: template argument list following class template name must list parameters in the order used in template parameter list
// Error: from<A,B>' : too few template arguments
template <bool B>
const std::string from<true, B>::value = "";
// full specialization - works …Run Code Online (Sandbox Code Playgroud) 在示例(regex.cpp)中,库的作者为此结构创建了自定义结构(magic_number)和验证函数,以显示如何将自定义结构集成到程序选项中.我按照他的例子为自定义类(MyClass)创建了一个验证函数.编译器抱怨lecical_cast不适用于MyClass.然后std::istream& operator>>(std::istream& in, MyClass& d),我实现,删除void validate(.., MyClass*, ..),代码编译.任何人都可以解释为什么这个例子不需要operator>>,而我的不需要validate?
编辑:
#include <MyLib/MyClass.h>
std::istream& operator>>(std::istream& in, MyClass& obj) {
// some code to populate obj
return in;
}
po::variables_map parseCommandLine(int argc, char* argv[]) {
po::options_description options("Options");
options.add_options()
("help", "produce help message")
("obj", po::value<MyClass>(), "")
;
po::variables_map vm;
store(po::command_line_parser(argc, argv)
.options(options).run(), vm);
notify(vm);
return vm;
}
int main(int argc, char* argv[]) {
try {
po::variables_map vm = parseCommandLine(argc, argv);
MyClass obj = vm["my"].as<MyClass>(); …Run Code Online (Sandbox Code Playgroud) 以下行是如何展开的?
template <class... Ts>
void print_all(std::ostream& os, Ts const&... args) {
(void(os << args), ...);
}
Run Code Online (Sandbox Code Playgroud)
应用规则,
一元右折(E op ...)变为E 1 op(... op(E N-1 op E N))
由cppreference提供,
E = void(os << args)
op = ,
Run Code Online (Sandbox Code Playgroud)
然后扩张成为
void(os << args[0], ..., (args[N-3], (args[N-2], args[N-1])) )
Run Code Online (Sandbox Code Playgroud)
?
怎么样
v.push_back(args), ...
Run Code Online (Sandbox Code Playgroud)
它变成了吗?
v.push_back(args[0], (args[1], ..., (args[N-2], args[N-1])))
Run Code Online (Sandbox Code Playgroud)
扩展和括号都令人困惑.有人解释一下吗?
SELECT Trade.TradeId, Trade.Type, Trade.Symbol, Trade.TradeDate,
SUM(TradeLine.Notional) / 1000 AS Expr1
FROM Trade INNER JOIN
TradeLine ON Trade.TradeId = TradeLine.TradeId
WHERE (TradeLine.Id IN
(SELECT PairOffId
FROM TradeLine AS TradeLine_1
WHERE (TradeDate <= '2011-05-11')
GROUP BY PairOffId
HAVING (SUM(Notional) <> 0)))
GROUP BY Trade.TradeId, Trade.Type, Trade.Symbol, Trade.TradeDate
ORDER BY Trade.Type, Trade.TradeDate
Run Code Online (Sandbox Code Playgroud)
当表开始增长时,我担心WHERE子句中IN的性能.有没有人对这种查询有更好的策略?子查询返回的记录数比TradeLine表中的记录数慢得多.TradeLine表本身以10 /天的速度增长.
谢谢.
编辑:我使用了将子查询从WHERE移动到FROM的想法.我投票支持了这个新查询的所有答案.
SELECT Trade.TradeId, Trade.Type, Trade.Symbol, Trade.TradeDate,
PairOff.Notional / 1000 AS Expr1
FROM Trade INNER JOIN
TradeLine ON Trade.TradeId = TradeLine.TradeId INNER JOIN
(SELECT PairOffId, SUM(Notional) AS Notional
FROM …Run Code Online (Sandbox Code Playgroud) 我有几个 Linq 查询。在语义上,它们是
a join b join c join d where filter1(a) && filter2(c) && filter3(d)
a join b join c where filter1(a) && filter2(c)
a join b join c join e where filter1(a) && filter2(c) && filter4(e)
...
我希望能够分解出共享部分:
a join b join c where filter1(a) && filter2(c)
Run Code Online (Sandbox Code Playgroud)
并动态附加join d和filter3(d)
有没有办法做到这一点?我已经在使用 Predicate Builder 来动态构建条件(过滤器)。
编辑:我正在使用 Linq-to-SQL。
编辑:基本查询如下所示:
from a in As.AsExpandable()
join b in Bs on a.Id equals b.PId
join c in Cs on b.Id equals …Run Code Online (Sandbox Code Playgroud) 我无法通过TestDriven运行的MbUnit测试中的Common.Logging框架将日志消息输出到控制台.我不确定它是否与Gallio在TestDriven注册的方式有关.我按照这篇文章中的步骤(使用TestDriven.Net注册Gallio zip安装)手动注册Gallio和TestDriven,因为我没有该机器的管理员权限.
相同的日志记录机制在NUnit + TestDriven中有效.