georgeandgeorge 2019-12-28
import random r1 = random.random() print(r1) # 0.2682469766947404 r2 = random.randint(1, 10) print(r2) # 10 r3 = random.uniform(1, 10) print(r3) # 5.296020606206669 r4 = random.randrange(0, 11, 2) print(r4) # 10 r5 = random.choice(["rose", "黄瓜丝", "面条"]) print(r5) # 黄瓜丝 list1 = [1, 2, 3, 4, 5] r6 = random.shuffle(list1) # None print(list1) # [4, 1, 2, 3, 5] r7 = random.sample(list1, 3) print(r7) # [3, 2, 5]