python中index什么意思_如何运用PYTHON里的index()

  • Post author:
  • Post category:python


1

打开PYTHON,新建一个PY文档。

90c61d1c99c0affcee483f9a2372941fbfe4ea66.jpg?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_500%2Climit_1

2

a = “I will never kiss a guy.”

b = a.index(“kiss”)

print(b)

index可以直接查找到字符串里面某个字符的位置。

955ea0e434daf05e5ced62c4751d96d81919e566.jpg?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_500%2Climit_1

3

help(a.index)

用HELP可以查看index的用法。