1import os
2def file_oprator(filename,type_of_prosess_on_file="w+",text=None):
3 """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"""
4 try:
5
6 do = open(filename,type_of_prosess_on_file)
7 if type_of_prosess_on_file == "w+" or type_of_prosess_on_file == "w" and os.path.isfile(filename):
8 do.write(text)
9 return text
10 else:
11 return do.read()
12 except:
13 return "an unexpected error occurred"
14 do.close()
15print(file_oprator("creating file with python function","w+","look i have created a file with a python function\nit was as simple as eating a cake\npython is very inportant for the feature"))
1import os
2
3newpath = r'C:\Program Files\arbitrary'
4if not os.path.exists(newpath):
5 os.makedirs(newpath)