python如何求数据的结尾?

函数:endswith()

作用:判断字符串是否以指定字符或子字符串结尾,常用于判断文件类型。

相关函数:判断字符串开头startswith()

函数说明:

语法:

string.endswith(str,beg[0,end=len(string)])

string[beg:end].endswith(str)