Professional Documents
Culture Documents
Program9 Done 16apr18
Program9 Done 16apr18
Program9 Done 16apr18
x = os.getcwd()
print "x is the current working dir of mine..= ",x
print "*******" * 5
def os_fun2():
x1 = os.listdir(".")
print "x1 = ", x1
def os_fun3():
x3 = os.listdir("My_test_dir")
print "x3 = ", x3
#commands
x=os.listdir("My_test_dir")
x4 = type(x)
print "the values given in the directory =", x
print "type of x4 is ",x4
x5 = len(x)
print "x5 = ", x5
#slicing of list:
x6 = x[:1]
print "no of files x6 =", x6
x6 = x[:]
print "no of files x6 =", x6
print "\n"
x7 = x[-1:]
print "x7 last one is ", x7
x7 = x[-2:]
print "x7 last one is ", x7
x8 = x[-5:]
print 'x8 is :', x8
print "****$$$****" * 5
#call fn1
os_fun1()
#call fn2
os_fun2()
#call fn3
os_fun3()
print "\n"
print "****$$$****" * 5
#call fn3a
my_result3 = os_fun3a("My_test_dir")
print "my_result3 =",my_result3
****************
Assignment:
1.import os:
implement the concept of multidepth folders (ie create folder1, and create another
folder named folder2 inside the folder1, create some files in folder 1 and
folder2 , then find the current working directory , get the list of files in
folders.
2. pass inside folder as a parameter to the function and then list the files..