mylist = [4, 9, 1, 8,10,30,100];
num = { "max":'', "min":'' };
for item in mylist: pass _max = num['max']; _min = num['min'];
# 判断是否为最大值 if _max == '': num['max'] = item; elif int(_max) < item: num['max'] = item; # 判断是否为最小值 if _min == '': num['min'] = item; elif int(_min) > item: num['min'] = item
print(num);
mylist = [4, 9, 1, 8,10,30,100];
num = { "max":'', "min":'' };
for item in mylist: pass _max = num['max']; _min = num['min'];
print(num);