码迷,mamicode.com
首页 > 编程语言 > 详细

【pyhon】字符串查找函数find(和java里的indexOf等效)

时间:2018-03-29 19:13:58      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:找不到   post   targe   indexof   style   com   color   返回   字符串查找   

# find和java里的indexOf相似,返回找到的位置,找不到返回-1
target=www.163.com
print(target.find(163))

if target.find(263)==-1:
    print(263不存在于字符串+target+)

 

【pyhon】字符串查找函数find(和java里的indexOf等效)

标签:找不到   post   targe   indexof   style   com   color   返回   字符串查找   

原文地址:https://www.cnblogs.com/xiandedanteng/p/8671061.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!