import random
key = 'abcde'
value = range(1, 6)
dictName=dict(zip(key, value))#{'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5}
def random_dic(dicts):#打乱字典,映射关系不变==================#
dict_key_ls = list(dicts.keys())#取键值keys,转化为list才能shuffle
random.shuffle(dict_key_ls)
new_dic = {} #创建空字典
for key in dict_key_ls:
new_dic[key] = dicts.get(key)#打乱后的key对应的value 赋值给空字典,结果有一位小数 ##一定是key??
return new_dic
print(random_dic(dictName))
arrxx=[1.0, 8.0, 4.0, 1.0, 1.0, 2.0, 8.0, 5.0, 2.0]
def intList(arr): #list里面的元素转化为整数================#
arr_temporary=[]
for item in arr:
item=int(item)
arr_temporary.append(item)
return(arr_temporary)