Read file contents

import sys, os

f = open(‘/path/to/file.xml’, ‘r’)

contents = f.read()

first_line = f.readline()
second_line = f.readline()

list_of_all_lines = f.readlines()

f.close()

 

http://docs.python.org/tutorial/inputoutput.html

 

Comments are closed.