0

I was trying to copy an image with the path : userDATA\user1\profile_image, but unfortunaly, I don`t know the file extention, because the user can drop his own image, so that the suffix is sometimes different.
file_path = drop_image_instance.image_path   # the path looks like this: C:\user\images\download1.png
copyfile(file_path, "userDATA\\" + username + "\\profile_image")

My question is, how can I find out, which suffix the file has, or how can i detect the ending in file_path? For example:

def find_suffix(path):
    file_ending = path[1]
    return file_ending

Thanks for answers!

  • 1
    Does this answer your question? [Extracting extension from filename in Python](https://stackoverflow.com/questions/541390/extracting-extension-from-filename-in-python) – costaparas Feb 07 '21 at 12:49
  • Great, but please remember to [search](https://stackoverflow.com/search) thoroughly next time. – costaparas Feb 07 '21 at 12:53

0 Answers0