获取文件后缀名

2021-12-12 21:31:09 星期日

def get_suffix(file_name, has_dot = False):
    pos = file_name.rfind(".")
    if 0 < pos < len(file_name)-1:
        if has_dot:
            index = pos
        else:
            index = pos + 1
        return file_name[index:]
    else:
        return 'None'


file_extension = get_suffix("123456.ccs", has_dot=0)
print(file_extension)
posted on 2021-12-12 21:26  geonos  阅读(2)  评论(0)    收藏  举报