这儿那儿
我现在有一个字符串如下
location1
{
type uniform;
axis y;
start (1000 -300 0.05 );
end (1000 9 0.05 );
nPoints 3000;
}
我叫它locationString。你知道吗
我试图找到这个字符串中所有括号(都是“(”&;“)”)的所有索引,如下所示
import re
kwSe='('
kwEe=')'
kwS=[match.start() for match in re.finditer(kwSe,str(locationString))]
kwE=[match.start() for match in re.finditer(kwEe,str(locationString))]
但这不管用,有人能帮忙吗?你知道吗
^{} 接受regex模式,而parentheses have special meaning接受regex模式(它们形成组)。如果要匹配文字
(
和)
,必须对它们进行转义(如\(
和\)
),或者将它们括在字符类中(如[(]
和[)]
)。你知道吗相关问题 更多 >
编程相关推荐