Skip to content

Commit 5a4febe

Browse files
committed
c05 p1
file open and read
1 parent 1c3d3d4 commit 5a4febe

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

C05/co5_p1.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#Write a Python program to read a file line by line and store it into a list.
2+
3+
fn = open("demo.txt",'r') #run in thonny (filename,mode)
4+
s= fn.readline() # for read line by line
5+
print(s)
6+
print(fn.closed) #file close status
7+
print(fn.mode) #file mode
8+
print(fn.name) #file name

C05/demo.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Python is a high-level, general-purpose programming language

0 commit comments

Comments
 (0)