File tree Expand file tree Collapse file tree
Sep21/EffectivePython/StandardLibrary/osandrelatedmodules Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import os
2+
3+
4+
5+ def current_cwd ():
6+ cwd = os .getcwd ()
7+ print (f"the current working directory is { cwd } " )
8+
9+ if __name__ == "__main__" :
10+ current_cwd ()
11+ os .chdir ("../" )
12+ current_cwd ()
13+ folder_path = os .path .join (os .getcwd (),'osandrelatedmodules' )
14+ os .chdir (folder_path )
15+ current_cwd ()
16+ parent_directory = os .getcwd ()
17+ data_dir = os .path .join (parent_directory ,"data" )
18+ if not os .path .exists (data_dir ):
19+ os .mkdir (data_dir )
20+
21+
22+ # recursive folder creation
23+ csv_dir = os .path .join (data_dir ,"files" , "csv" )
24+ if not os .path .exists (csv_dir ):
25+ os .makedirs (csv_dir )
26+
27+ parent_directory = "D:\\ khajaclassroom\\ python_intensive"
28+ dir_list = os .listdir (parent_directory )
29+ print (dir_list )
30+
31+ parent_directory = "D:\\ temp\\ test"
32+ for root , d_names , f_names in os .walk (parent_directory ):
33+ print (root ,d_names ,f_names )
34+
35+ # Commonly used functions
36+ print (os .name )
37+
38+ #os.rename(src="test.txt", dst="newtest.txt")
39+
40+ #os.path.getsize()
41+
42+
43+
44+
You can’t perform that action at this time.
0 commit comments