zoukankan      html  css  js  c++  java
  • django.db.models.query.QuerySet格式的数据输出

    1、

    def findmtm2(request):
    import serializer
    import json
    # 多对多跨表正向查询
    # res = softlist.objects.filter(hostlists__ip="10.116.6.177").values("softname")
    res2=softlist.objects.filter(hostlists__ip="10.116.9.233").values_list("softname")
    print("res2的数据输出是:",res2)

    print("res2的类型是:",type(res2))

    for nn in res2:
      print(nn,type(nn))


    for m in res2:
    # print(m,type(m))
      for mmm in m:
      print(mmm)

    return HttpResponse("ok,mtm2 search success!!!")

    ____________________________

    程序运行结果:

    res2的数据输出是: <QuerySet [('Acronis Backup',), ('Analytics Instance001',), ('CommCellConsole Instance001',), ('CommServe Instance001',), ('DiagnosticsAndUsageServer Instance001',), ('Java 8 Update 201 (64-bit)',), ('Java SE Development Kit 8 Update 201 (64-bit)',), ('MediaAgent Instance001',), ('MediaAgentCore Instance001',), ('MessageQueue Instance001',), ('Microsoft .NET Core Host - 2.1.16 (x64)',), ('Microsoft .NET Core Host - 2.1.5 (x64)',), ('Microsoft .NET Core Host FX Resolver - 2.1.16 (x64)',), ('Microsoft .NET Core Host FX Resolver - 2.1.5 (x64)',), ('Microsoft .NET Core Runtime - 2.1.16 (x64)',), ('Microsoft .NET Core Runtime - 2.1.5 (x64)',), ('Microsoft ASP.NET Core 2.1.16 Shared Framework (x64)',), ('Microsoft ASP.NET Core 2.1.5 Shared Framework (x64)',), ('Microsoft ASP.NET Core Module',), ('Microsoft Help Viewer 1.1',), '...(remaining elements truncated)...']>
    res2的类型是: <class 'django.db.models.query.QuerySet'>
    Acronis Backup
    Analytics Instance001
    CommCellConsole Instance001
    CommServe Instance001
    DiagnosticsAndUsageServer Instance001
    Java 8 Update 201 (64-bit)
    Java SE Development Kit 8 Update 201 (64-bit)

  • 相关阅读:
    poj 1017 Packets
    hdu 1058 The sum problem
    HDU 1205 吃糖果
    Hdu 1004 Let the Balloon Rise map解决方法
    poj 1700 贪心算法(1)
    大数计算器
    大整数的加减乘除取模
    【单调队列】poj 2823 Sliding Window
    【单调队列】bzoj 1407 [HAOI2007]理想的正方形
    【单调队列+二分查找】bzoj 1012: [JSOI2008]最大数maxnumber
  • 原文地址:https://www.cnblogs.com/yaok430/p/14721925.html
Copyright © 2011-2022 走看看