Python文字列endswith
startswith

endswith文字列

count

指定した文字列で終わるかどうかを返します。

構文

str.endswith(suffix, start?, end?)

使用例

下記の値を入力するとサンプルに即時反映されます。

filename
print
endswith
filename = "report.pdf"
print(filename.endswith(".pdf"))  # True
print(filename.endswith(".txt"))  # False