-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReading_Files.py
More file actions
33 lines (26 loc) · 1.1 KB
/
Copy pathReading_Files.py
File metadata and controls
33 lines (26 loc) · 1.1 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
""" _______________________________ """
#!""" Reading Files """
"""
| r r+ w w+ a a+
______________________|_______________________
read | + + + +
write | + + + + +
create | + + + +
truncate | + +
position at start | + + + +
position at end | + +
|
"""
# TRUNCATE -> Make the file empty
# CREATE -> Create new file if the file name doesn't exist
# SEE { https://github.com/HopeMashal/Python/blob/master/Workers.txt }
workers_file=open("Workers.txt","r")
for worker in workers_file.readlines():
print(worker)
workers_file.close()
# file_name.readable() --> check if the file open with read mode {OUTPUT:True/False}
# file_name.read() --> Read all file
# file_name.readline() --> Read the first line and put the cursor in the second line
# file_name.readlines() --> Read all lines and put them in array
# file_name.readlines()[# of line(from 0 to ..)] --> Read one line {Ex. workers_file.readlines()[1]}
""" _______________________________ """