Python字符串中startswith和endswith方法

mystr = 'hello world and gzy and java and python'

# startswith/endswith(子串。开始位置,结束位置)
print(mystr.startswith('hello')) #True
print(mystr.startswith('hi'))  #False
print(mystr.endswith('python'))  #True
print(mystr.endswith('Python'))  #False

posted @ 2021-03-08 15:34  code-G  阅读(115)  评论(0编辑  收藏  举报