I'm trying to get only the file name without extension, what I still get this error even though it's what it says in the book I'm trying to read.
import os
import re
stringA =[fname.rsplit(' ',0)[0] for fname in os.listdir("C:\\Users\\Desktop\\New folder\\New folder\\")]
stringA1 = os.path.splitext(os.path.basename(stringA))[0]
I get this error:
~\Anaconda3\lib\ntpath.py in basename(p)
214 def basename(p):
215 """Returns the final component of a pathname"""
--> 216 return split(p)[1]
217
218
~\Anaconda3\lib\ntpath.py in split(p)
183 Return tuple (head, tail) where tail is everything after the final slash.
184 Either part may be empty."""
--> 185 p = os.fspath(p)
186 seps = _get_bothseps(p)
187 d, p = splitdrive(p)
TypeError: expected str, bytes or os.PathLike object, not list