# 例子:
target='www.163.com'
print(target.find('163'))

if target.find('263')==-1:
    print('263不存在于字符串'+target+'')

 运行:

C:\Users\horn1\Desktop\python\7>python find.py
4
263不存在于字符串www.163.com中

 当然,如果仅仅是字符串里是否存在子串的话,使用 in 和 not in 操作符更好。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-04
  • 2022-12-23
  • 2021-12-12
  • 2021-10-19
  • 2021-04-01
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案