说明:本文实例讲述了python实现在字符串中查找子字符串的方法。分享给大家供大家参考。具体如下:
这里实现python在字符串中查找子字符串,如果找到则返回子字符串的位置,如果没有找到则返回-1
S = 'xxxxSPAMxxxxSPAMxxxx'
where = S.find('SPAM') # search for position
print where # occurs at offset 4
希望本文所述对大家的Python程序设计有所帮助。
<weixin_38526612> 上传 | 大小:29kb
说明:本文实例讲述了python的keyword模块用法。分享给大家供大家参考。具体如下:
Help on module keyword:
NAME
keyword - Keywords (from "graminit.c")
FILE
/usr/lib64/python2.6/keyword.py
DEscr iptION
This file is automatically generated; please don't muck it up!
To update the sym <weixin_38718434> 上传 | 大小:33kb