码迷,mamicode.com
首页 > 其他好文 > 详细

djnago unicode 转换成str list

时间:2015-10-14 22:10:54      阅读:243      评论:0      收藏:0      [点我收藏+]

标签:

from django.core.serializers.json import DjangoJSONEncoder

group_name = puppet_host.objects.filter(ip=ip).values_list(‘host_group‘,flat=True)
g_name = json.dumps(list(group_name), cls=DjangoJSONEncoder)


unicode 转换成list

definitions_list = [definition.encode("utf8") for definition in puppet_mod_host.objects.va
lues_list(‘mod_name‘, flat=True)]

还有一种办法 for

   for g in group_name:
        print g

参考网址:http://www.28im.com/python/a2239395.html

djnago unicode 转换成str list

标签:

原文地址:http://my.oschina.net/u/142602/blog/517253

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!