Navigation


RSS:   Blog / Fotos



Email desde Python

lunes 24 enero 2011 17:06:12, 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

miércoles 23 septiembre 2009 12:24:42, 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

miércoles 23 septiembre 2009 11:04:45, Python,

#!/usr/bin/env python

import hashlib, string, base64
m = hashlib.md5()
m.update("Some text")
print m.hexdigest()



About kope

Edo kopE
Edad: 30
Ubicacion actual:
B. Aires,
(Arg)
 

About Nero

Nero (okubi)
Edad: 57 @perro
Ubicacion actual:
Santiago, Chile



Categorias


Categorias Cookbook

Proyectos


Links