我是编码的新手,我想知道是否有办法简化这个:
if "!" in name or "$" in name or "%" in name or "^" in name or "&" in name or "*" in name or "(" in name or ")" in name or "_" in name or "-" in name or "+" in name or "=" in name:
points = points + 1
谢谢
答案 0 :(得分:3)
您可以使用正则表达式:
var btn = document.createElement("button");
var txt = document.createTextNode("Bought");
var div = document.getElementById("div");
btn.appendChild(txt);
$(btn).attr("id", "Btn1");
$(btn).addClass("btn btn-primary custom"); //add custom to allow hover css
$(btn).html("Click me");
div.appendChild(btn);
答案 1 :(得分:2)
withUnsafeMutablePointer(to: &nc) {
dgetrf_($0, $0, &matrix, $0, &ipiv, &info)
}
答案 2 :(得分:1)
您可以编写一个简单的函数来实现此目的。
def is_included(characters, sentence):
for character in characters:
if character in sentence:
return True
return False
正如mgilson所说,您也可以使用any
关键字。但是,由于您不熟悉编程,我建议您学习关键字的算法。