本文主要是介绍python中startswith和endswith的使用,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
转自:https://blog.csdn.net/zhangyun719927/article/details/75226428
startswith()和endswith()函数用于匹配字符串开头和结尾是否包含一个字符串,函数返回值为True或者False例如:
content='ceshicontent'
content.startswith('ceshi') #返回true
content.startswith('no') #返回false
content.endswith('tent') #返回true
content.endswith('con') #返回false
这篇关于python中startswith和endswith的使用的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!