fileObject.close()
[dywang@deyu zzz]$ cat fileio2.py
#!/usr/bin/python3
# Open a file
fo = open("fileio.txt", "ab+")
print("Name of the file:", fo.name)
print("1. Closed or not:", fo.closed)
# Close opend file
fo.close()
print("2. Closed or not:", fo.closed)
[dywang@deyu zzz]$ ./fileio2.py Name of the file: fileio.txt 1. Closed or not: False 2. Closed or not: True