問題:
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