赞
踩
html_format.py
#coding=utf-8
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
with open(sys.argv[1], 'r') as f:
data = f.readlines()
print '<table border="2" cellspacing="0" cellpadding="5" style="border-collapse: collapse;">'
print (unicode('<tr><th>姓名</th><th>性别</th><th>年龄</th><th>爱好</th><tr>', encoding="utf-8"))
for line in data:
values = line.split('\t')
print '<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>' % (values[0],values[1],values[2],values[3])
print '</table>'
linux中运行python脚本并将结果发送邮件:
result_data.txt为\t\n的文件
python ./html_format.py result_data.txt |formail -I "From: hlst@163.com" -I "MIME-Version:1.0" -I "Content-type:text/html;charset=utf8" -I "Subject:邮件主题"|/usr/sbin/sendmail -oi hlst1@163.com
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。