方法一、 str的endswith方法: cases_path = '测试用例1.xlsx' print(cases_path.endswith('.xlsx')) 返回结果: True 应用 判断后缀名的示例: cases = '测试用例1.xlsx