create a test file with two lines and verify that the file has been created by listing the directory again afterward : Directory « File « Python Tutorial






import os


fobj = open('test', 'w')
fobj.write('foo\n')
fobj.write('bar\n')
fobj.close()
print os.listdir('c:\\')








12.4.Directory
12.4.1.verify that '/tmp' is a valid directory and change to that temporary directory, call the getcwd() method
12.4.2.create a subdirectory in our temporary directory
12.4.3.create a test file with two lines and verify that the file has been created by listing the directory again afterward