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

Python 字符串中 startswith()方法

时间:2017-07-16 00:04:05      阅读:222      评论:0      收藏:0      [点我收藏+]

标签:bin   usr   python   ...   结果   blog   检查   tar   字符串   

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

str.startswith(str, beg=0,end=len(string));
#!/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 );

  结果:

True
True
False

  

Python 字符串中 startswith()方法

标签:bin   usr   python   ...   结果   blog   检查   tar   字符串   

原文地址:http://www.cnblogs.com/pengwang57/p/7187856.html

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