网络编程
位置:首页>> 网络编程>> Python编程>> Python判断以什么结尾以什么开头的实例

Python判断以什么结尾以什么开头的实例

作者:勿在浮沙筑高台LS  发布时间:2021-07-31 06:42:58 

标签:Python,判断,结尾,开头

如下所示:


str='abcdef'
print(str.endswith('f'))
print(str.startswith('a'))

输出结果:


True
True

str='abcdef'
print(str.endswith('f',0,4))
print(str.startswith('a',1))

输出结果:


False
False

来源:https://blog.csdn.net/baidu_15113429/article/details/77366160

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com