Extracting extension from filename in Python

后端 未结 24 2417
感情败类
感情败类 2020-11-22 13:23

Is there a function to extract the extension from a filename?

24条回答
  •  萌比男神i
    2020-11-22 14:04

    worth adding a lower in there so you don't find yourself wondering why the JPG's aren't showing up in your list.

    os.path.splitext(filename)[1][1:].strip().lower()
    

提交回复
热议问题