Enter a path to display all subdirectories in the file. Importosdeflist_all_path (path): ifos. path. isfile (path): print (path); globalcount; count + 1 print (count); else: ifos... enter a path to display all subdirectories in the file.
Import osdef list_all_path (path): if OS. path. isfile (path): print (path); global count; count + = 1 print (count); else: if OS. path. isdir (path): for sub_path in OS. listdir (path): list_all_path (path + "/" + sub_path); # This path is critical. it must be an absolute path. Otherwise, it cannot be recursive. count = 0; my_dir = input ("Enter a path:"); list_all_path (my_dir );
Count is the number of statistics
The running effect is as follows:
Enter a path: d:/workspacesd:/workspaces/MyEclipse 8.5 /. metadata /. bak_0.log1d:/workspaces/MyEclipse 8.5 /. metadata /. lock2d:/workspaces/MyEclipse 8.5 /. metadata /. log
With this program, you can add a judgment statement to filter all files with a keyword in the file name. The effect is similar to global search in windows. Continue to update later.