Extracting extension from filename in Python

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

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

24条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-22 14:06

    filename='ext.tar.gz'
    extension = filename[filename.rfind('.'):]
    

提交回复
热议问题