Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python close file

fileName = "stuff.txt" #insert file name
file = open(fileName)
#close the file
file.close()
Comment

close a file python

# read, write, close a file
# catch error if raise
try:
    file = open("tryCatchFile.txt","w") 
    file.write("Hello World")

    file = open("tryCatchFile.txt", "r")
    print(file.read())
except Exception as e:
    print(e)
finally:
    file.close()
Comment

close a file python

fileObject.close()
Comment

PREVIOUS NEXT
Code Example
Python :: split by backslash python 
Python :: poerty python macos 
Python :: get mode using python 
Python :: python library for downsampling a photo 
Python :: what are args and kwargs in python 
Python :: python binary 
Python :: python compare each item of one list 
Python :: shrink colorbar matplotlib 
Python :: strip characters from a string python 
Python :: tkinter mainloop 
Python :: string list to list 
Python :: what is the difference between accuracy and loss 
Python :: pandas get highest values row 
Python :: python string encode 
Python :: stack program in python3 
Python :: Remove whitespace from str 
Python :: print dtype of numpy array 
Python :: pyspark dataframe to dictionary 
Python :: python glob subdirectories 
Python :: array with zeros python 
Python :: Django delete a session value 
Python :: SUMOFPROD1 Solution 
Python :: create data frame in panda 
Python :: how to use ternary operater in python 
Python :: python decision tree 
Python :: python bool 
Python :: django.db.utils.IntegrityError: 
Python :: python zip files 
Python :: remove dups in list of tuples 
Python :: how to link button to the urls in django 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =