Python - Context Managers
What will be the output of this code?
with open('test.txt', 'w') as f:
f.write('Hello')
print(f.closed)What will be the output of this code?
with open('test.txt', 'w') as f:
f.write('Hello')
print(f.closed)with block effect on filewith block opens the file and closes it automatically after the block ends.f.closed after blockf.closed will be True.with block = True [OK]with block ends [OK]withf.closed value15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions