python function to create file and read file
import os
def file_oprator(filename,type_of_prosess_on_file="w+",text=None):
"""This is a function from which you can create files and read files it takes three inportant inputs one name of file which opration to do on file and text if you are using the create and write function"""
try:
do = open(filename,type_of_prosess_on_file)
if type_of_prosess_on_file == "w+" or type_of_prosess_on_file == "w" and os.path.isfile(filename):
do.write(text)
return text
else:
return do.read()
except:
return "an unexpected error occurred"
do.close()
print(file_oprator("creating file with python function","w+","look i have created a file with a python functionnit was as simple as eating a cakenpython is very inportant for the feature"))