Find the nth occurrence of substring in a string
问题 This seems like it should be pretty trivial, but I am new at Python and want to do it the most Pythonic way. I want to find the index corresponding to the n'th occurrence of a substring within a string. There's got to be something equivalent to what I WANT to do which is mystring.find("substring", 2nd) How can you achieve this in Python? 回答1: Mark's iterative approach would be the usual way, I think. Here's an alternative with string-splitting, which can often be useful for finding-related