str.endswith可以传入集合数据类型,而不仅仅是字符串
生活随笔
收集整理的這篇文章主要介紹了
str.endswith可以传入集合数据类型,而不仅仅是字符串
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
suffix = ("jpg", "png", "gif")
ss = "xxxx.jpn"
print(ss.endswith(suffix))
ss = "xxxx.jpg"
print(ss.endswith(suffix))輸出:
False
True
Help on method_descriptor:endswith(...)S.endswith(suffix[, start[, end]]) -> boolReturn True if S ends with the specified suffix, False otherwise.With optional start, test S beginning at that position.With optional end, stop comparing S at that position.suffix can also be a tuple of strings to try.
suffix can also be a tuple of strings to try.
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的str.endswith可以传入集合数据类型,而不仅仅是字符串的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: glue与clue的意思
- 下一篇: vim代码格式化工具autopep8