Writing And Appending To A File

Code file as described in the video

# f = open("harry.txt", "w")
# a = f.write("Harry bhai bahut achhe hain\n")
# print(a)
# f.close()

# f = open("harry2.txt", "a")
# a = f.write("Harry bhai bahut achhe hain\n")
# print(a)
# f.close()


# Handle read and write both
f = open("harry2.txt", "r+")
print(f.read())
f.write("thank you")
  


Comments(3)

ahmedraza at 2019-06-23 09:30:09 says
nice
ahmedraza at 2019-06-23 09:30:09 says
# f = open("harry.txt", "w") # a = f.write("Harry bhai bahut achhe hain\n") # print(a) # f.close() # f = open("harry2.txt", "a") # a = f.write("Harry bhai bahut achhe hain\n") # print(a) # f.close() # Handle read and write both f = open("harry2.txt", "r+") print(f.read()) f.write("thank you")
ahmedraza at 2019-06-23 09:30:09 says
hello