Home > other >  How to ask the python read directory folder and serial number
How to ask the python read directory folder and serial number

Time:10-22

To ask how to read the specified directory of all files and folders and give id and give the parent id


CodePudding user response:

 
The import OS

OS. Listdir (" D:/folder ")

CodePudding user response:

The
reference at the 1st floor response:
 
The import OS

OS. Listdir (" D:/folder ")

Number and give the parent id?

CodePudding user response:

refer to the second floor woobol response:
Quote: reference at the 1st floor response:
 
The import OS

OS. Listdir (" D:/folder ")

Number and give the parent id?


What is a number? What is a parent id?

CodePudding user response:

refer to the second floor woobol response:
Quote: reference at the 1st floor response:
 
The import OS

OS. Listdir (" D:/folder ")

Number and give the parent id?


To the ID of the file?

CodePudding user response:

Since the id, I have already written out, thank you

CodePudding user response:

 for root, dirs, files in OS. Walk "D: \ test" (r) : 
For file in files:
# get owning directory file
Print (root)
# file path
Print (OS) path) join (root, file))


 for root, dirs, files in OS. Walk "D: \ test" (r) : 
For dir in dirs:
# for directory name
Print (dir)
# for directory path
Print (OS) path) join (root, dir))
  • Related