Some time we have to create a file to store some data for our application and also read that file whenever we need it. So in this tutorial we will learn how to create a file on MAC system using python and also reading and writing on file.
1) Create a file :- In this function we just have to provide PATH and FILE_NAME. Please avoid to use private path where special permission is required.
name = path+'/'+filename # Name of text file coerced with +.txt
file = open(name,'a') # Trying to create a new file or open one
print('Something went wrong! Can\'t tell what?')
sys.exit(0) # quit Python
2) Write some content to file :- In this function we just have to provide PATH and get user input .User must press enter to finish his input to file.