zoukankan      html  css  js  c++  java
  • endswith()方法

    endswith()方法

    描述

    endswith() 方法用于判断字符串是否以指定后缀结尾,如果以指定后缀结尾返回True,否则返回False。可选参数"start"与"end"为检索字符串的开始与结束位置。

    语法

    endswith()方法语法:

    str.endswith(suffix[, start[, end]])

    参数

    • suffix -- 该参数可以是一个字符串或者是一个元素。

    • start -- 字符串中的开始位置,0 为第一个字符索引值。

    • end -- 字符中结束位置,1 为第一个字符索引值。

    返回值

    如果字符串含有指定的后缀返回True,否则返回False。

    实例

    以下实例展示了endswith()方法的实例:

    str1 = 'Runoob example....wow!!!'
    sufix = "!!"
    print(str1.endswith(sufix))
    print(str1.endswith(sufix, 20))
    
    sufix = "run"
    print(str1.endswith(sufix))
    print(str1.endswith(sufix, 0, 19))
    
    # 结果为
    # True
    # True
    # False
    # False
    print('01234'.endswith('234', 0, 4))
    >>> False
    
    print('01234'.endswith('234', 0, 5))
    >>> True
  • 相关阅读:
    [转载]解析用户生命周期价值:LTV
    [整理]VS2013常用插件
    Extjs4 tabpanel 中表单定宽居中
    idea创建ssm项目
    shiro框架的学习
    mysql
    springboot
    idea配置
    Spring MVC
    关于web乱码问题
  • 原文地址:https://www.cnblogs.com/xiaohei001/p/10121425.html
Copyright © 2011-2022 走看看