© 1999-2048 dssz.net 粤ICP备11031372号
[其它] python 查找字符串是否存在实例详解
说明:python中查找指定的字符串的方法如下: code #查询 def selStr(): sStr1 = 'jsjtt.com' sStr2 = 'com' #index查询某个字符串,返回索引 nPos = sStr1.index(sStr2) if(nPos >=0): print 'sStr1中包括sStr2中的字符' print nPos #find 方法如果没有查询到返回-1 nPos2 = sStr1.find('abc') pr<weixin_38693173> 上传 | 大小:27kb