File Handling In Python
File handling in Python is very simple
The most important thing is to import the os module which contains the libraries for all the functions with which you can perform file manipulations
Lets take a look at some simple code
import os for fileName in os.listdir ( '/home' ): print fileName
This will list all the files in the directory /home
import os os.mkdir("/home/user/TestDir")
This will create the TestDir in the absolute path specified as an argument to the function
import os os.rmdir("/home/user/TestDir")
This will delete the TestDir in the absolute path specified as an argument to the function
page revision: 1, last edited: 06 Apr 2008 01:36