startswith()

startswith() 是字符串的一个方法,用于判断字符串是否以指定的字符开头,如果是则返回True,否则返回False

In [1]: str = 'hello'

In [2]: str.startswith('h')
Out[2]: True

In [3]: str.startswith('he')
Out[3]: True

In [4]: str.startswith('He')
Out[4]: False

 

 

 

 

 

    

posted @ 2019-01-11 15:26  孔雀东南飞  阅读(157)  评论(0编辑  收藏  举报