1. 程式人生 > >random模塊知識點回顧

random模塊知識點回顧

使用 print rand randint 的區別 bsp -- 回顧 imp

import random

s = random.randint(2,4)

print(s)

s的輸出結果可能為 2,3,4

------------------------------------------------------------------------------------------------

import random

s1 = random.randrange(2,4)

print(s1)

s1的輸出結果可能有2,3

但是沒有4

--------------------------------------------------------------------------------------------------

這是兩者在使用時的區別!

random模塊知識點回顧