Mega Code Archive

 
Categories / Python Tutorial / File
 

Create a test file with two lines and verify that the file has been created by listing the directory again afterward

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