<> Method 1 :

Project name :InterfaceTest_master, root directory :InterfaceTest_master/
# Gets the directory of the current file cur_path = os.path.abspath(os.path.dirname(__file__)) # Get root directory
root_path= cur_path[:cur_path.find("InterfaceTest_master\\")+len(
"InterfaceTest_master\\")] print(root_path) # Create another directory data_path = os.path.abspath
(root_path +'\\excelReport') if not os.path.exists(data_path): os.mkdir(
data_path) # If this doesn't exist excelReport folder , Create one automatically print(data_path)
<> Operation results :
C:\Users\Administrator\Desktop\InterfaceTest_master\ C:
\Users\Administrator\Desktop\InterfaceTest_master\excelReport
<> Method 2 :
# Get root directory base_dir = dirname(dirname(abspath(__file__))) print(base_dir) #
Revised to linux catalog base_dir = base_dir.replace('\\', '/') print(base_dir) # Create another directory
file_path= base_dir + "/excelReport" print(file_path)
<> Operation results :
C:\Users\Administrator\Desktop\InterfaceTest_master C:/Users/Administrator/
Desktop/InterfaceTest_master C:/Users/Administrator/Desktop/InterfaceTest_master
/excelReport

Technology
©2020 ioDraw All rights reserved
Huawei Hongmeng system learning notes 9- Ecological construction of developers JavaScript Do a simple guess number games Centralized processing (mean centering) The myth and truth of JS Experimental summary of basic key knowledge ( whole ) Detailed explanation PHP Medium die,exit,returnPython Student information management system ( Lite )re Common methods of modules stata Basic operation of linear regression analysis flutter study -- Search box Docker Import of containers and mirrors , export