>>> help(str.count)
Help on method_descriptor:
count(...)
S.count(sub[, start[, end]]) -> int
Return the number of non-overlapping occurrences of substring sub in
string S[start:end]. Optional arguments start and end are
interpreted as in slice notation.
您可以使用正则表达式来查找它。使用来自模块re的函数findall查找重叠出现
结果是2。在
或者在这里得到3:
^{pr2}$注意不重叠。在
相关问题 更多 >
编程相关推荐