[Solved] python – history file


If you are trying to delete this lines from the file, try this:

import os

def removeUrl(url):
    url_file = "url.txt"
    fileIn = open(url_file, 'r')
    fileOut = open("temp.txt", 'w')
    for line in fileIn:
        if url not in line:
            fileOut.write(line)
    fileIn.close()
    fileOut.close()

    os.remove(url_file)
    os.rename("temp.txt", url_file)

removeUrl("www.youtube.com")

solved python – history file