python function to create file and read file

Solutions on MaxInterview for python function to create file and read file by the best coders in the world

showing results for - "python function to create file and read file"
Dario
22 Jun 2019
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"))
Said
04 Jun 2019
1import os
2 
3newpath = r'C:\Program Files\arbitrary' 
4if not os.path.exists(newpath):
5    os.makedirs(newpath)
queries leading to this page
how to create a file through pythonpython create filecreate files with pythonpython open and create filecreate a file using pythonpython open create filepython open or create file for writingpython how to create a filecreate file using pythonpython make filehow to make any file in pythonpython function to create file and read filecreating a file in the python create a file with pythonhow to create a new file in pyhtonhow to create a file using pythoncreate and open file in pythoncreate python filepython program to create files and read fileshow to create a file puthoncreate new file in pythoncreate a python file in pythoncreate a file in pythonhow to make a new file in pythonhow to make a file using pytohnpython file createhow to make new file in pythonopen create file pythoncreate file python 27how to create a file in pythoncreate a file pythonpython to make python filepython codecs open create filehow to create a new file in pytohncreate files in pythoncreate a file in pythonhow to make a file in python 3create file and open pythoncreate file pythoncreate and open a file in pythoncreate new file pythonhow to make a file using pythonmake new file pythoncreating new file in pythoncreate file pythponpython open file or createhow to create file in pythonhow to make a file in pythonhow to create a new file in pytonmake file in pythonhow to write a file create a file using pythonpython make new filehow to create a new file using pythoncreate file in python with openhow to make files in pythonhow to create a python file in pythoncreate file in pythoncreate a new file pythonhow to create a file with pythonhow to create a file pythonhow to make file in pythonhow to make a python file a bach filecreate a file from pythonpython create new filepython create a filehow ro create file in pythonpython create file pythoniccreating a file in pythoncreate files pythonhow to create a file using pytho npython create new file and write and readcreate file with pythonmake file pythonpython open or create filemake a file pythoncreate and open file pythonpython creating new filepython how to make new filecreate new file in python and writepython create a new filepython 2c create filecreate files using pythonhow to create a new file in pythonread or create file pythonmake files with pythonhow to create and read a file in pythonpython create file and readcreate file in pythhonhow do i create a file in pythonhow to create files in pythonhow to create new file in pythonhow to make a file with ythonpython function to create file and read file