Extracting extension from filename in Python

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

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

24条回答
  •  鱼传尺愫
    2020-11-22 14:11

    name_only=file_name[:filename.index(".")
    

    That will give you the file name up to the first ".", which would be the most common.

提交回复
热议问题