baseFunction.py 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. def TuplefindInList(lists: list, args):
  2. for l in lists:
  3. if args in l:
  4. return l
  5. return None
  6. def TuplefindInList1(lists: list, args, numb): #单一条件查询
  7. res = []
  8. if lists:
  9. for l in lists:
  10. if args == l[numb]:
  11. res.append(l)
  12. break
  13. return res
  14. def TuplefindInList11(lists: list, args, numb): #单一条件查询
  15. res = []
  16. if lists:
  17. for l in lists:
  18. if args == l[numb]:
  19. res.append(l)
  20. return res
  21. def TuplefindInList111(lists: list, args): #单一条件查询
  22. res = []
  23. if lists:
  24. for l in lists:
  25. for numb in range(3, 9):
  26. if args == l[numb].replace("*",""):
  27. res.append(l)
  28. break
  29. return res
  30. def TuplefindInList2(lists: list, args, args2, numb): # 或双条件查询
  31. res = []
  32. if lists:
  33. for l in lists:
  34. if args == l[numb] or args2 == l[numb]:
  35. res.append(l)
  36. return res
  37. def TuplefindInList3(lists: list, args, numb,neednumb): #唯一单一条件查询 并获取指定字段 #字符串类型
  38. res = ""
  39. if lists:
  40. for l in lists:
  41. if args == l[numb]:
  42. res = l[neednumb]
  43. break
  44. return res
  45. def TuplefindInList33(lists: list, args, numb,neednumb): #唯一单一条件查询 并获取指定字段 #字符串类型
  46. res = []
  47. if lists:
  48. for l in lists:
  49. if args == l[numb]:
  50. res.append(l[neednumb])
  51. return res
  52. def TuplefindInList4(lists: list, args, numb): # #唯一单一条件查询 并获取指定字段#列表类型
  53. res = []
  54. if lists:
  55. if lists !=None and len(lists) != 0:
  56. for l in lists:
  57. if args == l[numb]:
  58. res=l[2]
  59. return res
  60. def TuplefindInList5(lists: list, numb, args,numb2, args2): #且双条件查询
  61. res = []
  62. if lists:
  63. for l in lists:
  64. if args == l[numb] and args2 == l[numb2]:
  65. res.append(l)
  66. return res
  67. def TuplefindInList6(lists: list, args, args2, args3, numb): # 或三条件查询
  68. res = []
  69. if lists:
  70. for l in lists:
  71. if args == l[numb] or args2 == l[numb] or args3 == l[numb]:
  72. res.append(l)
  73. return res
  74. def TuplefindInList7(lists: list, args, numb,numb2): #单一条件查询 且返回指定字段字符串
  75. res = ""
  76. if lists:
  77. for l in lists:
  78. if args == l[numb]:
  79. res=res+"、"+l[numb2] if res != "" else l[numb2]
  80. return res
  81. def TuplefindInList8(lists: list, args, numb): #单一条件查询不等于
  82. res = []
  83. if lists:
  84. for l in lists:
  85. if args != l[numb]:
  86. res.append(l)
  87. return res
  88. def TuplefindInList9(lists: list, numb): #单一条件查询求和
  89. res = 0
  90. if lists:
  91. for l in lists:
  92. if l[numb] !="":
  93. res = res+float(l[numb])
  94. return round(res,2)