Skip to content

Commit 321be6b

Browse files
committed
# read multiple line
1 parent 43763fb commit 321be6b

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

C05/co5_p1.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,22 @@
1111

1212
fo =open("demo2.txt","w")
1313

14-
fo.write("Python is dynamically-typed and garbage-collected. It supports multiple programming paradigms")
14+
fo.write("Python is dynamically-typed and garbage-collected \n. It supports multiple programming paradigms")
1515
fo.close()
1616

17+
""" #replace data in file
1718
f2 =open("demo2.txt","w")
1819
f2.write("Python gdgg")
1920
f2.close()
21+
"""
22+
23+
fn1 =open("demo2.txt","r")
24+
s1 =fn1.readline()# read multiple line
25+
s2 =fn1.readline()
26+
27+
print(s1)
28+
print(s2)
29+
fn1.close()
30+
2031

2132

C05/demo2.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
Python gdgg
1+
Python is dynamically-typed and garbage-collected
2+
. It supports multiple programming paradigms

0 commit comments

Comments
 (0)