# import libraries import sys , os ,shutil,glob, string , re ,datetime #===================================== # IO Samples #===================================== # read file line by line f= open ('text.txt','r') for line in f: print string . split (line, '\n')[0] #remove linebreak # read file all at once f= open ('text.txt','r') text = f. read () print (text) #current directory print os .getcwd() #list files/folders in current directory for file in os .listdir( os .getcwd()): print file # print directory structure def printDir( path ,indent): for root, dirs, files in os .walk( path ): for name in dirs: print indent+ name printDir( os . path . join (root, name ),indent+" ") for name in files: print indent+ name printDir( os .getcwd()) #create dir os .mkdir(" Test ") #delete dir os .remove(" Test ") #execute command os .system(" mkdir x ") #exe