[Tutor] HTML Project--in plain text format i hope
Paul Brown
clanoftheinsane@hotmail.com
Sun, 15 Jul 2001 16:27:21 -0400
ok, maybe everyone can read this without any trouble now. my original
message was:
hey all,
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:
import sys
file=open('c:\windows\desktop\goodtext', 'r')
br="Date:"
for line in file.readlines():
if line[:5] != br:
if line[:-1]=="\n":
print "<p>", line,
else:
print line,
else:
sys.stdout.write(line[5:])
print '''<html>
<head>
<title>%s</title>
</head>
<BODY>
<center><h1>%s</h1></center>
''' %(line[5:], line[5:])
any suggestion? thanks,
paul brown
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com