How can I find the file list extension. I am currently using os.path.splitext, which does not work. Please suggest any other method in case of file list.
My code is here:
files = request.FILES.getlist('media') for f in files: p = os.path.splitext(f)[1] print p
Error displayed here 'InMemoryUploadedFile' object has no attribute 'rfind'
'InMemoryUploadedFile' object has no attribute 'rfind'
Thanks in advance
From the error and the code, it seems that you are using Django, so you should get the name of the object and not the object itself as:
p = os.path.splitext(f.name)[1]
which will give the file name, not the file.
Source: https://habr.com/ru/post/1674715/More articles:How to calculate the distance in the meaning of two words in Python - pythonIs there a MERN-like stack for VueJS? - mongodbHow to push .txt.gz file on git - githow to make a rectangle at runtime to match the draggable word label in it. - iosHow can I repeat the content (aka * ngFor) without a wrapping element? - angularMySQL datetime for echo in PHP - phpRefreshing SignalR page makes multiple connections - c #Matching in a list of vectors with different lengths - listWrapping C ++ code with python (manually) - c ++Problems with iGraph and disparityfilter with characters and large numbers - rAll Articles