问题:
How can I count the number of times a given substring is present within a string in Python?如何计算给定子字符串出现在 Python 字符串中的次数?
For example:例如:
>>> 'foo bar foo'.numberOfOccurrences('foo')
2
解决方案:
参考一: https://stackoom.com/question/bLGr参考二: Count number of occurrences of a substring in a string