Read Write To Files

Computer Science | Artificial Intelligence | Computational Biology | Chess | Blender

Read Write To Files

My all mighty one, yee that rights to files and reads from them, I have a project for you. I have a project that involves reading and writing to files, oh! the great. I have a file that I want to read from and write to like a whatsapp chat could be.

Read Write To Files

import os

# Read the file
def read_file():
    with open('yourFileName.txt', 'r') as file:
        print(file.read())

read_file()

# Create the file and write to it
def write_file():
    with open('yourFileName.txt', 'w') as file:
        file.write('Yee, I'm a guy who loves to code')
        file.write('See ya later, person who loves to code')

write_file()