-
Notifications
You must be signed in to change notification settings - Fork 0
/
ex2_1.py
22 lines (19 loc) · 850 Bytes
/
ex2_1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
""" Open the "show_version.txt" file for reading. Use the .read() method to read
in the entire file contents to a variable. Print out the file contents to the screen.
Also print out the type of the variable (you should have a string at this point).
Close the file.
Open the file a second time using a Python context manager (with statement).
Read in the file contents using the .readlines() method. Print out the file
contents to the screen. Also print out the type of the variable (you should
have a list at this point).
"""
from __future__ import print_function, unicode_literals
f=open("show_version.txt",'r')
output=f.read()
f.close()
print(output)
print("\n********************\n",type(output))
with open("show_version.txt") as f:
lines=f.readlines()
print("\n********************\n",lines)
print("\n********************\n",type(lines))