#!/bin/env python
#-*- coding:utf-8 -*-
# multiple searches of a string for a substring
# using s.find(sub[ ,start[, end]])
text = "create table t11 (id int,name varchar(20),age int,status varchar(10),sary int unsigned)"
search = 'int'
start = 0
while True:
index = text.find(search, start)
# if search string not found, find() returns -1
# search is complete, break out of the while loop
if index == -1:
break
print( "%s found at index %d" % (search, index) )
# move to next possible start position
start = index + 1
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/91975/viewspace-2126984/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/91975/viewspace-2126984/