Tuesday, 5 February 2019

Python Script to create File and append 10 dummy lines on every function call

def createFolder():
   try:
        if not os.path.exists(directory):
            os.makedirs(directory)
            return 'FolderCreated'
            return 'FolderNotCreated'

     f = open("/home/raghu/Desktop/raghu1234.txt","a+")

     for i in range(10):
        f.write("This is the line %d\r\n" % (i+1))

     f.close()

# FunctionCall
createFolder()

No comments:

Post a Comment

Git

1 git add ↳ It lets you add changes from the working directory into the staging area 2 git commit ↳ It lets you save a snapshot of currently...