from random import randint
dict = {}
l = []
for i in range (0,1000):#规定循环次数
s = randint(0,99)
l.append(s)
print(dict.fromkeys(l,11))
法二
list1 = []
list2 = []
from random import randint
for i in range(0,1000):
list1.append(randint(0,99))
list1.append(randint(0,99))
if len(list1)==2:
list2.append(list1)
list1 = []
print(dict(list2))
法三
dict1 = {}
from random import randint
for i in range(0,10000):
a = randint(0,99)
b = randint(0,99)
dict1.setdefault(a,b)
if len(dict1)==1000:
break
print(dict1)
print(len(dict1))
法四
from random import randint
list1 =[]
list2 =[]
for i in range(0,100):
a = randint(0,99)
b = randint(0,99)
list1.append(a)
list2.append(b)
print(dict(zip(list1,list2)),end=" ")
法五
import random
list = []
dict={}
for i in range(0,100):
for k in range(0,100):
key1 = random.uniform(0, 99)
list.append(key1)
dict.setdefault(key1,i)
if len(dict) == 1000:
break
if len(dict) == 1000:
break
print(dict)
print(len(dict.keys()))
法一from random import randintdict = {}l = []for i in range (0,1000):#规定循环次数 s = randint(0,99) l.append(s)print(dict.fromkeys(l,11))法二list1 = []list2 = []from random import randintfo...