当前位置:  首页>> 技术小册>> 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