我想做的是:
if (article.find("(")) and not (article.find(")")):
然而,它似乎不起作用。任何帮助表示赞赏。谢谢!
答案 0 :(得分:2)
NSString *Str_embbed_video = [NSString stringWithFormat:@"\
<html><head>\
<style type=\"text/css\">\
body {\
background-color: black;\
color: transparent;\
}\
</style>\
</head><body style=\"margin:0\">\
<video width=\"%0.0f\" height=\"%0.0f\" controls autoplay=\"true\" poster=\"%@\" webkit-playsinline\> <source src=\"%@\" type=\"video/mp4\" ></video>\
</body></html>",webviewFrame.size.width,webviewFrame.size.height,imageurlString,videoUrlString];
[webView loadHTMLString:Str_embbed_video baseURL:[[NSBundle mainBundle] resourceURL]];
你想要失败时返回0的东西。 Help on built-in function find:
find(...)
S.find(sub [,start [,end]]) -> int
Return the lowest index in S where substring sub is found,
such that sub is contained within S[start:end]. Optional
arguments start and end are interpreted as in slice notation.
Return -1 on failure.
运算符执行此操作。
答案 1 :(得分:1)
使用in
,and not in
。
if '(' in article and not ')' in article:
示例:强>
>>> a = '(sdk'
>>> if '(' in a and not ')' in a:
print('yah')
yah
>>> a = '(sdk)'
>>> if '(' in a and not ')' in a:
print('yah')
>>> a = 'sdk'
>>> if '(' in a and not ')' in a:
print('yah')
>>>
答案 2 :(得分:-1)
$('table').on('click', 'td:nth-child(3)', function () {
$(this).next().toggle();
// | |
// | ^-- this selects the next sibling
// |
// ^-- `this` is a reference to the clicked td
});