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