Quotes help make search much faster. Example: "Practice Makes Perfect"

Monday, October 28, 2013

#Python #Codecademy File Input/Output PSA: Buffering Data


# Sample solution


# Open the file for reading
read_file = open("text.txt", "r")

# Use a second file handler to open the file for writing
write_file = open("text.txt", "w")
# Write to the file
write_file.write("Not closing files is VERY BAD.")

write_file.close()

# Try to read from the file
print read_file.read()
read_file.close()

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts