import re text2="hellp密码:wokhgaksf名字:zhangsan" 字符串如上, 定位方式如下: data= re.findall('.*密码:(.*?)名字', text)[0]