open('file.txt', 'r')open('file.txt', 'w')open('file.txt', 'a')open('file.txt', 'x')read()readline()readlines()content()write()writelines()append()put()open('file.txt', 'w')open('file.txt', 'r')open('file.txt', 'a')open('file.txt', 'x')readline()read()readlines()next()'r''w''a''x''r''w''r+''a+''a''r''w''x''r''w+''r+''a''r+''a''w''x''b''t''x''bin'read()readline()readlines()readbin()write()writelines()writebin()wb()'wb''ab''wt''w'f.read()f.readlines()f.read(10)close()exit()stop()end()read(num_bytes)readline(num_bytes)readlines(num_bytes)seek(num_bytes)tell()seek()position()getpos()seek(position)tell(position)goto(position)move(position)readlines()read()readline()content()FileNotFoundErrorIOExceptionPermissionErrorValueErrortry-excepttry-finallytry-except-finallyFileNotFoundErrorValueErrorIOErrorAttributeErrorFileNotFoundErrorPermissionErrorOSErrorValueErrortry-except blockfinally blockwith statementopen() methodwith statement when working with files?
with open('file.txt', 'r') as f: syntax do in Python?
with statement in Python?
with statement, what happens if an exception occurs within the block?
with open('file.txt', 'r') as file:open('file.txt', 'r') as file:open('file.txt')with open() as file:| Question No. | Answer |
|---|---|
| 1 | a |
| 2 | a |
| 3 | a |
| 4 | a |
| 5 | a |
| 6 | c |
| 7 | c |
| 8 | c |
| 9 | c |
| 10 | d |
| 11 | a |
| 12 | a |
| 13 | a |
| 14 | d |
| 15 | d |
| 16 | a |
| 17 | a |
| 18 | a |
| 19 | a |
| 20 | a |
| 21 | a |
| 22 | d |
| 23 | c |
| 24 | b |
| 25 | a |
| 26 | a |
| 27 | a |
| 28 | a |
| 29 | a |
| 30 | a |