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 删除。