首页 > 其他 > 详细

string的方法find

时间:2018-11-28 21:24:10      阅读:175      评论:0      收藏:0      [点我收藏+]

官方解释:find(sub[, start[, end]]) Return the lowest index in the string where substring sub is found within the slice s[start:end]. Optional arguments start and end are interpreted as in slice notation. Return -1 if sub is not found.(返回在切片s [start:end]中找到substring sub的字符串中的最低索引。可选参数start和end被解释为切片表示法。如果未找到sub,则返回-1。)

In [142]: print(s13.find(‘skyler‘)) # 查找a出现的位置
2

In [143]: print(s13.find(‘walter‘)) # 查找Walter的位置,如果没有则返回-1
-1

In [144]: print(s13.find(‘a‘, 8, 22)) # 切片找
20

string的方法find

原文:https://www.cnblogs.com/lcfzh/p/10034453.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!