互联网技术 / 互联网资讯 · 2024年3月15日

Python3-endswith()方法在云计算开发中的详细解析

描述

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

语法

以下是 endswith() 方法语法:

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

参数

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

start — 字符串中的开始位置。

end — 字符中结束位置。

返回值

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

实例

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

云计算开发:Python3-endswith()方法详解

以上实例输出结果如下:

云计算开发:Python3-endswith()方法详解

OpenMagic API

Need more than content? Move into the product flow.

If you are here for model access, pricing, developer docs, or the future API console, the dedicated product path now lives on api.openmagic.ai.