Use the imported library os
import us
Use the function os.listdir() to display the files under the folder in the form of a list
import os
filedir = r"D:\test"
# isdir 判断路径是否为目录
if os.path.isdir(filedir):
print(os.listdir(filedir))
for file in os.listdir(filedir):
print(file)
print result