*Guarda esto en un json:* {"groups": {"1": {"fields": {"1": {"widget_type": "DropDownList", "options": {"00005": {"text": "Si"}, "00006": {"text": "No"}}, "name": "\u00bfHoy Trajiste a Clase tu XO?", "dependence": "00001"}, "0": {"widget_type": "DropDownList", "options": {"00004": {"text": "No"}, "00003": {"text": "Si"}}, "name": "\u00bfRecibiste en Alg\u00fan Momento tu XO?", "dependence": "00001"}, "2": {"widget_type": "DropDownList", "options": {"00007": {"text": "Totalmente Sana"}, "00009": {"text": "No Funciona"}, "00008": {"text": "Parcialmente Sana"}}, "name": "\u00bfC\u00faal es el Estado Actual de tu XO?", "dependence": "00001"}}, "name": "Datos de XO"}, "0": {"fields": {"0": {"widget_type": "RadioButton", "options": {"00001": {"text": "Si"}, "00002": {"text": "No"}}, "name": "\u00bfEl Alumno se Encuentra en Clase?", "dependence": ""}}, "name": "Asistencia"}, "3": {"fields": {"0": {"widget_type": "TextInput", "options": {"00017": {"text": ""}}, "name": "Comentarios", "dependence": "00001"}}, "name": "Comentarios"}, "2": {"fields": {"0": {"widget_type": "MultipleCheckBox", "options": {"00023": {"text": "Jugar con el Robot"}, "00020": {"text": "Programar"}, "00025": {"text": "Pegarle a mi hermano"}, "00024": {"text": "Jugar al Ping Pong"}, "00021": {"text": "Editar mi Blog"}, "00016": {"text": "Grabar videos"}, "00022": {"text": "Dibujar"}, "00014": {"text": "Escuchar M\u00fasica"}, "00015": {"text": "Ver Videos"}, "00012": {"text": "Estudiar"}, "00013": {"text": "Leer"}, "00010": {"text": "Facebook"}, "00011": {"text": "Juegos"}, "00026": {"text": "Jugar con el perro"}, "00027": {"text": "Para Nada"}, "00018": {"text": "Sacar Fotos"}, "00019": {"text": "Chatear"}}, "name": "\u00bfPara qu\u00e9 Utilizas tu XO?", "dependence": "00001"}}, "name": "Uso de la XO"}}}
El 20 de marzo de 2013 19:41, Andrey Antukh <n...@niwi.be> escribió: > Si crees que no he entendido la pregunta, por que vuelves a repetir lo > mismo? > Y partiendo del hecho de que no he entendido la pregunta, creo que sigo > sin entender cual es tu duda. > > Andrey > > > El 20 de marzo de 2013 23:36, Flavio Danesse <fdane...@gmail.com>escribió: > > No entendiste la pregunta. >> >> Era: >> >> que pasa si en tu aplicación tienes un diccionario bien grande con >> diccionarios, listas, etc . . . anidados >> quieres guardarlo todo y de una en un json? >> >> >> El 20 de marzo de 2013 17:31, Andrey Antukh <n...@niwi.be> escribió: >> >> Es muy simple: >>> >>> >>> import io >>> >>> import json >>> >>> kk = {str(x):u"kákà" for x in range(1000)} >>> >>> with io.open("foo.json", "wb") as f: >>> ... json.dump(kk, f) >>> ... >>> >>> >>> >>> with io.open("foo.json", "rb") as f: >>> ... kk2 = json.load(f) >>> ... >>> >>> len(kk2.keys()) >>> 1000 >>> >>> kk2[1] >>> Traceback (most recent call last): >>> File "<stdin>", line 1, in <module> >>> KeyError: 1 >>> >>> print kk2["1"] >>> kákà >>> >>> Andrey >>> >>> >>> El 20 de marzo de 2013 20:52, Flavio Danesse <fdane...@gmail.com>escribió: >>> >>> ok >>>> >>>> Esto funciona para guardar una cadena con tildes, pero que pasa si en >>>> tu aplicación tienes un diccionario bien grande con diccionarios, listas, >>>> etc . . . anidados y quieres guardarlo todo y de una en un json? >>>> >>>> >>>> >>>> El 20 de marzo de 2013 16:40, Andrey Antukh <n...@niwi.be> escribió: >>>> >>>> Modulo json fue incorporado en python 2.6 tomando como codigo base >>>>> simplejson. >>>>> La regla principal, es usar siempre siempre y siempre, unicode (sea >>>>> con UTF-8, UTF-16 o UTF-32) (para nuestro caso es utf-8). >>>>> Y no habra problemas. Si no cuidas el encoding con el que editas los >>>>> ficheros, pueden pasarte esas cosas. >>>>> >>>>> Usar un modulo externo y decir que es una solucion al problema, lo >>>>> unico que dice es que el problema sigue ahi, y que el modulo que usas >>>>> traga >>>>> mas mierda y sea menos estricto, pero de ninguna manera te ha solucionado >>>>> el problema de encoding. >>>>> >>>>> >>> import json >>>>> >>> kk = u"cadená con tìldes" >>>>> >>> dd = json.dumps({"foo": kk}) >>>>> >>> dd >>>>> '{"foo": "caden\\u00e1 con t\\u00ecldes"}' >>>>> >>> print json.loads(dd) >>>>> {u'foo': u'caden\xe1 con t\xecldes'} >>>>> >>> print json.loads(dd)['foo'] >>>>> cadená con tìldes >>>>> >>>>> Un saludo. >>>>> Andrey >>>>> >>>>> >>>>> El 20 de marzo de 2013 20:29, Flavio Danesse <fdane...@gmail.com>escribió: >>>>> >>>>> yo tuve el mismo problema que él y esta fue la solución. >>>>>> >>>>>> La verdad no sabia que json era de python y simplejson no. >>>>>> >>>>>> El 20 de marzo de 2013 16:20, Andrey Antukh <n...@niwi.be> escribió: >>>>>> >>>>>> El 20 de marzo de 2013 19:53, Flavio Danesse >>>>>> <fdane...@gmail.com>escribió: >>>>>>> >>>>>>>> import simplejson >>>>>>>> archivo = open(path, 'w') >>>>>>>> archivo.write(simplejson.dumps(salida)) >>>>>>>> archivo.close() >>>>>>>> >>>>>>>> >>>>>>> No entiendo la necesidad de liar a una persona con bibliotecas >>>>>>> que están fuera de python, cuando la pregunta va directa sobre un >>>>>>> modulo de >>>>>>> python. >>>>>>> >>>>>>> >>>>>>> >>>>>>>> >>>>>>>> El 20 de marzo de 2013 15:35, Diego Uribe Gamez < >>>>>>>> diego.uribe.ga...@gmail.com> escribió: >>>>>>>> >>>>>>>> estoy usando nano, >>>>>>>>> >>>>>>>>> para lo que me pregunto quique: >>>>>>>>> >>>>>>>>> print u"%s" % var >>>>>>>>> UnicodeDecodeError: 'ascii' codec can't decode byte 0xf3 in >>>>>>>>> position 53: ordinal not in range(128) >>>>>>>>> >>>>>>>>> lo que sucede es que var biene de otro archivo y es un string, no >>>>>>>>> logro codificarlo. >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> El 20 de marzo de 2013 13:33, Alberto Chamorro < >>>>>>>>> a.chamorro.r...@gmail.com> escribió: >>>>>>>>> >>>>>>>>> Aun asi da cosa ver ASCII Java program text! ¿Que editor utilizas? >>>>>>>>>> On Mar 20, 2013 7:12 PM, "Quique Porta" <quiquepo...@gmail.com> >>>>>>>>>> wrote: >>>>>>>>>> >>>>>>>>>>> ¿Has probado esto? >>>>>>>>>>> var = *u*"texto con tildes, Categorías " >>>>>>>>>>> >>>>>>>>>>> poniendo la "u" delante de la cadena >>>>>>>>>>> >>>>>>>>>>> El 20 de marzo de 2013 18:56, Diego Uribe Gamez < >>>>>>>>>>> diego.uribe.ga...@gmail.com> escribió: >>>>>>>>>>> >>>>>>>>>>>> tan raro yo no sabia y tampoco entiendo: >>>>>>>>>>>> >>>>>>>>>>>> file texto.py >>>>>>>>>>>> texto.py: ASCII Java program text >>>>>>>>>>>> >>>>>>>>>>>> sobre el encabezado esta el # -*- coding: utf-8 -*- >>>>>>>>>>>> correctamente >>>>>>>>>>>> >>>>>>>>>>>> Como hago para saber con un print el tipo de codificación antes >>>>>>>>>>>> de hacer el encode('utf-8')? >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> El 20 de marzo de 2013 12:25, Alberto Chamorro < >>>>>>>>>>>> a.chamorro.r...@gmail.com> escribió: >>>>>>>>>>>> >>>>>>>>>>>>> Si lo tienes en un fichero .py comprueba la codificacion con >>>>>>>>>>>>> la que has guardado el fichero (en unix seria con el comando file) >>>>>>>>>>>>> >>>>>>>>>>>>> Tambien se recomienda añadir a los programas la linea de >>>>>>>>>>>>> coding: >>>>>>>>>>>>> >>>>>>>>>>>>> # -*- coding: utf-8 -*- >>>>>>>>>>>>> >>>>>>>>>>>>> Un saludo >>>>>>>>>>>>> >>>>>>>>>>>>> _______________________________________________ >>>>>>>>>>>>> Python-es mailing list >>>>>>>>>>>>> Python-es@python.org >>>>>>>>>>>>> http://mail.python.org/mailman/listinfo/python-es >>>>>>>>>>>>> FAQ: http://python-es-faq.wikidot.com/ >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> -- >>>>>>>>>>>> *Diego Alonso Uribe Gamez* >>>>>>>>>>>> ------------------------------ >>>>>>>>>>>> >>>>>>>>>>>> *Desarrollador web* >>>>>>>>>>>> >>>>>>>>>>>> Twitter: @DiegoUG <http://www.twitter.com/DiegoUG> >>>>>>>>>>>> >>>>>>>>>>>> Google+: http://gplus.to/diegoug >>>>>>>>>>>> ------------------------------ >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> _______________________________________________ >>>>>>>>>>>> Python-es mailing list >>>>>>>>>>>> Python-es@python.org >>>>>>>>>>>> http://mail.python.org/mailman/listinfo/python-es >>>>>>>>>>>> FAQ: http://python-es-faq.wikidot.com/ >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> _______________________________________________ >>>>>>>>>>> Python-es mailing list >>>>>>>>>>> Python-es@python.org >>>>>>>>>>> http://mail.python.org/mailman/listinfo/python-es >>>>>>>>>>> FAQ: http://python-es-faq.wikidot.com/ >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>> _______________________________________________ >>>>>>>>>> Python-es mailing list >>>>>>>>>> Python-es@python.org >>>>>>>>>> http://mail.python.org/mailman/listinfo/python-es >>>>>>>>>> FAQ: http://python-es-faq.wikidot.com/ >>>>>>>>>> >>>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> -- >>>>>>>>> *Diego Alonso Uribe Gamez* >>>>>>>>> ------------------------------ >>>>>>>>> >>>>>>>>> *Desarrollador web* >>>>>>>>> >>>>>>>>> Twitter: @DiegoUG <http://www.twitter.com/DiegoUG> >>>>>>>>> >>>>>>>>> Google+: http://gplus.to/diegoug >>>>>>>>> ------------------------------ >>>>>>>>> >>>>>>>>> >>>>>>>>> _______________________________________________ >>>>>>>>> Python-es mailing list >>>>>>>>> Python-es@python.org >>>>>>>>> http://mail.python.org/mailman/listinfo/python-es >>>>>>>>> FAQ: http://python-es-faq.wikidot.com/ >>>>>>>>> >>>>>>>>> >>>>>>>> >>>>>>>> _______________________________________________ >>>>>>>> Python-es mailing list >>>>>>>> Python-es@python.org >>>>>>>> http://mail.python.org/mailman/listinfo/python-es >>>>>>>> FAQ: http://python-es-faq.wikidot.com/ >>>>>>>> >>>>>>>> >>>>>>> >>>>>>> >>>>>>> -- >>>>>>> Andrey Antukh - Андрей Антух - <n...@niwi.be> >>>>>>> http://www.niwi.be/about.html >>>>>>> http://www.kaleidos.net/A5694F/ >>>>>>> >>>>>>> "Linux is for people who hate Windows, BSD is for people who love >>>>>>> UNIX" >>>>>>> "Social Engineer -> Because there is no patch for human stupidity" >>>>>>> >>>>>>> _______________________________________________ >>>>>>> Python-es mailing list >>>>>>> Python-es@python.org >>>>>>> http://mail.python.org/mailman/listinfo/python-es >>>>>>> FAQ: http://python-es-faq.wikidot.com/ >>>>>>> >>>>>>> >>>>>> >>>>>> _______________________________________________ >>>>>> Python-es mailing list >>>>>> Python-es@python.org >>>>>> http://mail.python.org/mailman/listinfo/python-es >>>>>> FAQ: http://python-es-faq.wikidot.com/ >>>>>> >>>>>> >>>>> >>>>> >>>>> -- >>>>> Andrey Antukh - Андрей Антух - <n...@niwi.be> >>>>> http://www.niwi.be/about.html >>>>> http://www.kaleidos.net/A5694F/ >>>>> >>>>> "Linux is for people who hate Windows, BSD is for people who love UNIX" >>>>> "Social Engineer -> Because there is no patch for human stupidity" >>>>> >>>>> _______________________________________________ >>>>> Python-es mailing list >>>>> Python-es@python.org >>>>> http://mail.python.org/mailman/listinfo/python-es >>>>> FAQ: http://python-es-faq.wikidot.com/ >>>>> >>>>> >>>> >>>> _______________________________________________ >>>> Python-es mailing list >>>> Python-es@python.org >>>> http://mail.python.org/mailman/listinfo/python-es >>>> FAQ: http://python-es-faq.wikidot.com/ >>>> >>>> >>> >>> >>> -- >>> Andrey Antukh - Андрей Антух - <n...@niwi.be> >>> http://www.niwi.be/about.html >>> http://www.kaleidos.net/A5694F/ >>> >>> "Linux is for people who hate Windows, BSD is for people who love UNIX" >>> "Social Engineer -> Because there is no patch for human stupidity" >>> >>> _______________________________________________ >>> Python-es mailing list >>> Python-es@python.org >>> http://mail.python.org/mailman/listinfo/python-es >>> FAQ: http://python-es-faq.wikidot.com/ >>> >>> >> >> _______________________________________________ >> Python-es mailing list >> Python-es@python.org >> http://mail.python.org/mailman/listinfo/python-es >> FAQ: http://python-es-faq.wikidot.com/ >> >> > > > -- > Andrey Antukh - Андрей Антух - <n...@niwi.be> > http://www.niwi.be/about.html > http://www.kaleidos.net/A5694F/ > > "Linux is for people who hate Windows, BSD is for people who love UNIX" > "Social Engineer -> Because there is no patch for human stupidity" > > _______________________________________________ > Python-es mailing list > Python-es@python.org > http://mail.python.org/mailman/listinfo/python-es > FAQ: http://python-es-faq.wikidot.com/ > >
_______________________________________________ Python-es mailing list Python-es@python.org http://mail.python.org/mailman/listinfo/python-es FAQ: http://python-es-faq.wikidot.com/