[Python-es] Error codificación carácteres
Raúl Cumplido
raulcumplido en gmail.com
Lun Feb 28 23:17:51 CET 2011
Hola,
He creado tu ejemplo en my base de datos de test. Prueba esto a ver:
import MySQLdb
conn = MySQLdb.connect (host="localhost", user=XXXXXXXXXX,
passwd=YYYYYYYYYYYYYY, db="test")
cursor = conn.cursor()
cursor.execute("select id, Nombre from cotizaciones_valores where id=1")
resultado=cursor.fetchone()
>>> print(resultado)
('1', 'telef\xc3\xb3nica Espa\xc3\xb1a')
id_Valor= resultado[0]
Nombre_Valor= resultado[1]
print(Nombre_Valor)
<<<<<<<<<<<<<<<<<< telefónica España
archivo_configuracion= open( 'gnuplot.dem', 'w')
archivo_configuracion.write("set title '%s (%s)'\n" % ( Nombre_Valor,
id_Valor,))
archivo_configuracion.close()
archivo_configuracion = open('gnuplot.dem', 'r')
linea = archivo_configuracion.readline()
print(linea)
<<<<<<<<<<<<<<<<<<<set title 'telefónica España (<built-in function id>)'
archivo_configuracion.close()
Yo también estoy aprendiendo, eh! Así que si alguien ve algo que esté muy
mal que avise, xD!
Saludos,
Raúl
2011/2/28 Dr. Bobus <drbobus en gulic.org>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> El Mon, 28 Feb 2011 20:08:15 +0100
> Jesús Genicio <jgenicio en gmail.com> dijo:
>
> >
> > He intentado utilizar tu código pero me da errores igualmente.
> >
> > He adjuntado a pastebin el código completo, si alguien me puede
> > ayudar...
> >
> > http://pastebin.com/x3DFTkjD
> >
>
>
> Hola Jesus:
>
> ¿En la linea 25 de tu código type(resultado[ 1]) que devuelve ??
>
>
> Saludos
>
>
> Dr. Bobus
>
> - --
> [In 'Doctor' mode], I spent a good ten minutes telling Emacs what I
> thought of it. (The response was, 'Perhaps you could try to be less
> abusive.')
> (Matt Welsh)
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
>
> iEYEARECAAYFAk1sFm8ACgkQVO2xr8e6gc5EtQCcCvB5TeeQUekZBFFSiBet2sfY
> FmcAniMSpzChi92K2MKR7Vi40pcoToP/
> =fs0E
> -----END PGP SIGNATURE-----
> _______________________________________________
> Python-es mailing list
> Python-es en python.org
> http://mail.python.org/mailman/listinfo/python-es
> FAQ: http://python-es-faq.wikidot.com/
>
--
Raúl Cumplido
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://mail.python.org/pipermail/python-es/attachments/20110228/bbd652cd/attachment.html>
Más información sobre la lista de distribución Python-es