You can get
the file object using ‘with’ keyword. One advantage of ‘with’ keyword is, file
is properly closed after its suite finishes, even if an exception is raised on
the way.
>>> with open('/Users/harikrishna_gurram/abc.txt', 'r') as f: ... read_data = f.read() ... print(read_data) ... 0123456789abcdef >>> >>> f.closed True
No comments:
Post a Comment