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]]) -> bool
Return 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.