首页 > 编程语言 > 详细

python之判断字符串以何关键字开头

时间:2021-06-30 18:31:00      阅读:16      评论:0      收藏:0      [点我收藏+]
(str.startswith(‘关键字‘) is True:以关键字开头 False:不以关键字开头
还可以指定关键字所处位置:
#!/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 );

python之判断字符串以何关键字开头

原文:https://www.cnblogs.com/mollyliu/p/14954055.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!