-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLect_016.py
More file actions
46 lines (41 loc) · 1.18 KB
/
Lect_016.py
File metadata and controls
46 lines (41 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File writing tutorial.
f = open("file-io-test.txt", "r")
#############################################
# Practise 1
# In this practise we can saw the output of
# the whole file.
#
# content = f.read()
# print(content)
#############################################
#############################################
# Practise 2
# # First 3 words printing.
# content = f.read(3)
# print(content)
#
# # Next 3 words printing after 1st read.
# content = f.read(3)
# print(content)
#############################################
#############################################
# Practise 3
# content = f.read(255)
# print("1", content)
#
# content = f.read(255)
# print("2", content)
#############################################
#############################################
# Printing file character via For Loop.
# for line in f:
# print(line, end="")
# Note: end="" in removing blank line from the
# FOR LOOP.
#############################################
#############################################
# Printing via f.readline function.
print("1.", f.readline(),end="")
print("2.", f.readline(),end="")
#############################################
f.close()