File creaaated is .txt by default, how to change it to some other extension?

My code is as follows and I am working on a Linux machine

import time as t
from os import path

def createFile(dest):
    
    date = t.localtime(t.time())
    
    ##Fileame = Month_Day_Year
    name = "%d_%d_%d.txt"%(date[1],date[2],date[0]%100)
    
    if not(path.isfile(dest+name)):
        f = open(dest + name, 'w')
        f.write('\n'*30)
        f.close()
    
if __name__ == '__main__':
    destination = "/home/user/projects/python/python1/"
    createFile(destination)
    print "done!!!"

Now it is creating a file intended in .txt format (why?) and how can I change that, say I want it to be a ,html file.

Edit: yeah, solved, I am an idiot.

change the .txt to .html?

2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.