import os
from os import listdir
from os.path import isfile, join
mypath=print(os.getcwd()) # prints the current working directory
all_files = [f for f in listdir(mypath) if isfile(join(mypath, f))]
print(all_files) # prints the list of files in a folder
here are the errors?
i need help….why i have the following error?
File c:usersptumidocumentsiamachinelearningcoursdatacours1lm.py:25
all_files = [f for f in listdir(mypath) if isfile(join(mypath, f))]
File c:usersptumidocumentsiamachinelearningcoursdatacours1lm.py:25 in
all_files = [f for f in listdir(mypath) if isfile(join(mypath, f))]
File :108 in join
TypeError: expected str, bytes or os.PathLike object, not NoneType
i try to print the content of a folder
But at the following instruction i have an error :
all_files = [f for f in listdir(mypath) if isfile(join(str(mypath), f))]
i have this error:
all_files = [f for f in listdir(mypath) if isfile(join(mypath, f))]
File :108 in join
TypeError: expected str, bytes or os.PathLike object, not NoneType
Taikiken Kyokushin Pat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.