Changes

Jump to: navigation, search

OPS435 Python Lab 5

3 bytes added, 16:44, 4 September 2017
PART 1 - Reading Data From Files
dir(f)
</source>
:#Although the '''dir(f)''' function displays a lot of information, we will focus on only a few elements. Separately issue Issue all of the following commands in order to inspect some of the '''functions'''. '''attributes''' and '''methods''' that we can use with this file object:<source lang="python">
help(f.read) # help for reading all lines and stores in a string
help(f.readlines) # help for reading all lines and stores in a list
help(f.readline) # help for reading first line, if run a second time it will read the second line, then third
help(f.writable) # help for determining if writing all lines and stores in a file is writablestring
help(f.close) # help for closing the opened file
f.writable() # Object method (function returns value)
13,420
edits

Navigation menu