Email desde Python
#!/usr/bin/python
# -*- coding: utf-8 -*-
import smtplib
from email.mime.text import MIMEText
# configuraciones smtp
server = mail.dominio.com
puerto = 25
user = usuario
password = password
msg = MIMEText ('Cuerpo del mensaje')
msg['Subject'] = 'Título'
msg['From'] = 'Nombre '
msg['To'] = 'destinatario@dominio.com'
s = smtplib.SMTP (server, puerto)
s.login (user, password)
s.sendmail (msg[From], 'destinatario@dominio.com', msg_as_string())
s.quit
print ('Mensaje enviado ;)')
Leer datos desde archivo en python
cat datos.txt
Nombre: Juan Apellido: Perez Edad: 30
#!/usr/bin/env python
for line in open("datos.txt"):
line=line.strip()
if "Nombre" in line:
firstname = line.split(":")[1]
if "Apellido" in line:
lastname = line.split(":")[1]
if "Edad" in line:
age = line.split(":")[1]
print "Nombre = " + firstname
print "Apellido = " + lastname
print "Edad = " + age
Md5 en Python
#!/usr/bin/env python
import hashlib, string, base64
m = hashlib.md5()
m.update("Some text")
print m.hexdigest()
Nero (okubi)