Python dengan file
with open(filename, 'r') as f:
Steve-Tech
with open(filename, 'r') as f:
>>> with open('workfile') as f:
... read_data = f.read()
>>> # We can check that the file has been automatically closed.
>>> f.closed
True
with open('output.txt', 'w') as file: # Use file to refer to the file object
file.write('Hi there!')