import textfiles
# Open a file: file
file = open('opa.txt','r')
# Print it
print(file.read())
# Check whether file is closed
print(file.closed)
# Close file
file.close()
# Check whether file is closed
print(file.closed)
context manager
it is important to close an open file. a way to do this automaticaly is to use a context manager. Out of the context everything will be automatically closed.
you can bind a variable
file
by using a context manager construct:
with open('huck_finn.txt') as file:
with open('huck_finn.txt') as file:
print(file.read())
Numpy
- standard for storing numerical data -essential for other packages scikit-learn (machine learning)
Geen opmerkingen:
Een reactie posten