[Python] How can I get a file extension from a filetype?

Discussão em 'Python' iniciado por Stack, Julho 23, 2025.

  1. Stack

    Stack Membro Participativo

    I have a list of filenames as follows:

    files = [
    '/dl/files/4j55eeer_wq3wxxpiqm.jpg',
    '/home/Desktop/hjsd03wnsbdr9rk3k',
    'kd0dje7cmidj0xks03nd8nd8a3',
    ...
    ]


    The problem is most of the files do not have an extension in the filenames, what would be the best way to get file extension of these files?

    I don't know if this is even possible because Python would treat all files as buffer or string objects that do not have any filetype associated with them.

    Can this be done at all?

    Continue reading...

Compartilhe esta Página