python - history file -


i have project

i'm making text browser , need help

i have history file every url , time, put in history file like:

www.youtube.com 2016-06-29 13:47:15.986000

www.youtube.com 2016-06-29 13:47:22.416000

www.youtube.com 2016-06-29 13:47:31.962000

www.youtube.com 2016-06-29 13:47:40.713000

www.youtube.com 2016-06-29 13:47:49.193000

i need make remove func gets url, , removes lines

(the lines separated "\n")

this code of history file:

def update_history(url):     thistime = str(datetime.datetime.now())     urlat = url + " " + thistime     history = open("somthing.txt" , "w")     history.write(urlat)     history.write("\n") 

please my, it's tomorrow!

if trying delete lines file, try this:

import os  def removeurl(url):     url_file = "url.txt"     filein = open(url_file, 'r')     fileout = open("temp.txt", 'w')     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") 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -