表达式:
random.randint(参数1,参数2)
(1)参数1、参数2必须是整数
(2)函数返回参数1和参数2之间的任意整数
1 import random 2 number = random.randint(1,100) 3 print(number) 4 5 输出: 6 7 7 8 Process finished with exit code 0
number = [random.randint(1,100) for i in range(10)]
1 import random 2 number1 = random.randint(1,100) 3 number2 = [random.randint(1,100) for a in range(10)] 4 print(number1,number2) 5 6 输出: 7 25 [46, 17, 50, 86, 55, 22, 31, 48, 49, 24] 8 9 Process finished with exit code 0