当前位置:  首页>> 技术小册>> Python合辑4-130个字符串操作示例

如何在 Python 字符串中找到第一次出现的子字符串

  1. test = 'Position of a character'
  2. print(test.find('of'))
  3. print(test.find('a'))

Output:

  1. 9
  2. 12