首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >Python中字符串匹配函数startswith()函数

Python中字符串匹配函数startswith()函数

作者头像
用户7886150
修改2021-01-11 10:17:39
修改2021-01-11 10:17:39
1.9K0
举报
文章被收录于专栏:bit哲学院bit哲学院

参考链接: Python | 字符串startswith

1.函数用途含义 

 Python startswith() 方法用于检查字符串是否是以指定子字符串开头,如果是则返回 True,否则返回 False。如果参数 beg 和 end 指定值,则在指定范围内检查。 

 2.用法 

 Str.startswith(str, beg=0,end=len(string)); 

 Str是需要匹配的字符串str是待检测子字符串beg默认为0表示从第一个字符开始匹配end表示终止匹配的位置

 3.实例 

 #!/usr/bin/python

str = "this is string example....wow!!!";

print str.startswith( 'this' );

print str.startswith( 'is', 2, 4 );

print str.startswith( 'this', 2, 4 );

out:

True

True

False 

转载于:https://www.cnblogs.com/tsruixi/p/11431978.html

本文系转载,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文系转载前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档