![]() | Python has a rich cross-platform operating system (OS) interface |
![]() | Skip Unix- or DOS-specific commands; do all OS operations in Python! |
![]() | Safe creation of a subdirectory:
dir = case # subdirectory name import os, shutil if os.path.isdir(dir): # does dir exist? shutil.rmtree(dir) # yes, remove old files os.mkdir(dir) # make dir directory os.chdir(dir) # move to dir |