将文本排版转化为html中相同的排版。 为google blog服务
1 2 3 4 5 6 7 8 9 | #文本原样到html中
#对换行符的处理
#需求产生于:Google Blog
line_break="\n"
data=file("e://untitled.txt","r").read()
out=data.replace(line_break,"<br/>")
file("c://out.txt","w").write(out)
|
Tags: html
将文本排版转化为html中相同的排版。 为google blog服务
1 2 3 4 5 6 7 8 9 | #文本原样到html中
#对换行符的处理
#需求产生于:Google Blog
line_break="\n"
data=file("e://untitled.txt","r").read()
out=data.replace(line_break,"<br/>")
file("c://out.txt","w").write(out)
|
Well this is not very helpful, you need to do a lot more for a real HTML conversion. And why would you write out to .txt instead of .html? E.g. converting some Wiki-Markup to HTML converts Lists to <ul> elements and the like would be also necessary for a more interesting use case
Sure, you're winning a place inside the PyPy team with such awesome scripts... Waiting for html2txt version (a one liner maybe ?).
Please do not clutter up the recipe space with such trivialities, otherwise you might as well make "print 'hello world'" a recipe...