Mega Code Archive

 
Categories / Python / File
 

Working with File Objects

# Python has a built-in function, open, for opening a file on disk.  # open returns a file object, which has methods and attributes for getting  # information about and manipulating the opened file. f = open("aFile.txt", "rb")         print f                                             print f.mode                                        print f.name