[英]How do I list all files of a directory?
import os print("Python Program to print list the files in a directory.") Direc = input(r"Enter the path of the folder: ") print(f"Files in the directory: {Direc}") files = listdir(Direc) files = [f for f in files if os.path.isfile(Direc+'/'+f)] #Filtering only the files. print(*files, sep="\n")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.