[Tutor] HTML project
Paul Brown
clanoftheinsane@hotmail.com
Sat, 14 Jul 2001 21:11:29 -0400
<html><DIV>hey all,</DIV>
<DIV>i am working on a project with Python. some of my friends have a email-list going around, and somebody writes a daily (well, almost daily) devotional and sends it to everyone. i'm wanting to put all of these on a website, and i'm gonna use python to write the html files. i've got most of what i want complete, but i can't figure out the rest. all of the devotionals i have saved into a big text document, separated by a common string: "Date:" and then it displays the date, in the form of Month ##th, 2000. (or "st" and "2001" in their respective places). i want to create an actual HTML file in the following format: month##.html (all lowercase, double digits for the numbers to keep them in order). what i've got so far is the python script that prints the whole file to the stdout, and it inserts the headings with the appropriate dates. another thing i want to do is have the script write in the paragraph tag (<p>) whenever there is two linebreaks. would that be possible? here is my script so far:</DIV>
<DIV> </DIV>
<DIV>import sys<BR>file=open('c:\windows\desktop\goodtext', 'r')</DIV>
<DIV>br="Date:"</DIV>
<DIV>for line in file.readlines():<BR> if line[:5] != br:<BR> if line[:-1]=="\n":<BR> print "<p>", line,<BR> else:<BR> print line,<BR> else:<BR> sys.stdout.write(line[5:])<BR> print '''<html><BR><head><BR><title>%s</title><BR></head><BR><BODY></DIV>
<DIV><center><h1>%s</h1></center><BR>''' %(line[5:], line[5:])</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>any suggestions? thanks</DIV>
<DIV>paul brown</DIV><br clear=all><hr>Get your FREE download of MSN Explorer at <a href="http://explorer.msn.com">http://explorer.msn.com</a><br></p></html>