|
14 | 14 | # print(f.read()) |
15 | 15 |
|
16 | 16 | ## read and print whole file : |
17 | | -# with open('test.txt','r') as f: |
| 17 | +# with open('C:\\Users\\lev\\Documents\\OpsGuru\\projects\\Devops-course\\devops-python\\files_os_module\\test.txt','r') as f: |
18 | 18 | # f_contents = f.read() |
19 | 19 | # print(f_contents) |
20 | 20 |
|
21 | 21 | ## read and print line by line file: |
22 | 22 | # with open('test.txt','r') as f: |
23 | | -# with open('test.txt','r') as f: |
| 23 | +# with open('test.txt','r') as fa: |
24 | 24 | # # f_contents = f.readlines() |
25 | | -# f_contents = f.readlines() |
| 25 | +# f_contents = fa.readlines() |
26 | 26 | # print(f_contents) |
27 | 27 |
|
28 | 28 | ## read and print single line, first one every time we call function readline will read next line (copy and show) |
|
39 | 39 |
|
40 | 40 | ## More control for reading , explanation of read buffer |
41 | 41 | # with open('test.txt','r') as f: |
42 | | -# f_contents = f.read() |
43 | | - # f_contents = f.read(100) # copy and explain |
44 | | - # print(f_contents, end='') |
| 42 | +# # f_contents = f.read() |
| 43 | +# f_contents = f.read(100) # copy and explain |
| 44 | +# print(f_contents, end='') |
45 | 45 |
|
46 | 46 | ## More contr eol for big files with while and EOF condition in while loop, also f.tell() and f.seek() |
47 | 47 | # with open('test.txt','r') as f: |
|
88 | 88 | # suppose you want to make a subfolder under your home folder: $HOMEPATH/python-project/project1/temp |
89 | 89 | # folder_name = os.path.join(os.environ['HOMEPATH'],'python-project','project1','temp') |
90 | 90 | # os.makedirs(folder_name) |
91 | | - |
| 91 | +# class |
92 | 92 | ## Walking throught directories and files : |
93 | 93 | # for dirpath, dirname, filename in os.walk(os.environ['HOMEPATH']): |
94 | 94 | # print('Current path',dirpath) |
|
0 commit comments