if a pypthon string doesn't end with an extension, how to add ".jpg" to it
- User
if a pypthon string doesn't end with an extension, how to add ".jpg" to it
- Assistant
To add the extension
".jpg"to a Python string that doesn't already have an extension, you can use theos.path.splitext()function from theosmodule. This function splits the pathname into a pair(root, ext)such thatextis everything starting from the last period (.) in the last pathname component (i.e., the file extension). Here's how you can do it: