Writing scripts in Python under a Linux system certainly does not prevent various directories and folders. For easy reference in the future, simply summarize the directory and folder-related operations in Python.
The module that needs to implement the import is: import OS
1. Get the current working directory, which is the directory path of the current Python script work:
PATH=OS.GETCWD ()
Here is a good example from: The Journey of the Gum
We put abc.py into the a folder. And you can create a new folder within the A folder, regardless of where you put the a folder on your hard disk. and the name of the folder is automatically generated based on time.
Import OS Import = time.strftime (R"%y-%m-%d_%h-%m-%s", Time.localtime ()) Os.makedirs (R '%s/%s'% (OS.GETCWD (), folder))
2. Return all file and directory names under the specified directory:
Os.listdir ()
(after work, go back to update ...) )
[Python] directory and file operations