How can I create a file in python?
Pernelle Marone-Hitz
Member, Moderator, Employee Posts: 871
✭✭✭✭
Answers
-
The following function can be used:
import os def CreateFile(filePath): ''' create the file filePath if not existing :param filePath: path of file ''' try: if not (filePath and os.path.isfile(filePath)): # if the file doesn't exist, let's create it open(filePath, 'a').close() except: ExtAPI.Log.WriteError("Error : Exception in CreateFile()")
0