Jul-25-2019, 10:02 AM
Do anyone know how to read a file, and write into html with the correct link page.
i have a file name test.txt, which contain:
www.google.com
www.cnn.com
If i write as below, it will not link to correct link page. Do anyone know why? What shall i correct, if i want to link correct place.
How to i let it display on html which will have this two link.
i also try with this
same
i have a file name test.txt, which contain:
www.google.com
www.cnn.com
If i write as below, it will not link to correct link page. Do anyone know why? What shall i correct, if i want to link correct place.
1 2 3 4 5 6 7 8 9 10 11 12 |
with open ( 'test.txt' ) as f, open ( 'out.html' , 'w' ) as f_out: for line in f: line = line.strip() #print("<a href=",line ,"</a>","link") #print (line1) f_out.write( '{}<br>' . format ( '<a href="line">Link </a>' )) hyperlink_format = '<a href="{link}">{text}</a>' |
i also try with this
1 |
f_out.write( '{}<br>' . format ( '<a href="+line+">Link </a>' )) |