資料參考:
https://www.cnblogs.com/masked/p/8846439.html Python__random庫基本介紹
https://www.runoob.com/python/func-number-random.html Python random() 函數
import os
from random import choice
# 如果你有一個圖片文件夾,想隨機性的選擇圖片,就可以這樣寫
path_ = "圖片文件夾地址"
path_list = os.listdir(path_ )
path_random = choice(path_list)
print(path_list)
print(path_random)
# 隨機圖的最終地址
image = path_+'\\'+path_random
print(image)

import random
import string
# 隨機整數:
print random.randint(1,50)
# 隨機選取0到100間的偶數:
print random.randrange(0, 101, 2)
# 隨機浮點數:
print random.random()
print random.uniform(1, 10)
# 隨機字符:
print random.choice('abcdefghijklmnopqrstuvwxyz!@#$%^&*()')
# 多個字符中生成指定數量的隨機字符:
print random.sample('zyxwvutsrqponmlkjihgfedcba',5)
# 從a-zA-Z0-9生成指定數量的隨機字符:
ran_str = ''.join(random.sample(string.ascii_letters + string.digits, 8))
print ran_str
# 多個字符中選取指定數量的字符組成新字符串:
print ''.join(random.sample(['z','y','x','w','v','u','t','s','r','q','p','o','n','m','l','k','j','i','h','g','f','e','d','c','b','a'], 5))
# 隨機選取字符串:
print random.choice(['剪刀', '石頭', '布'])
# 打亂排序
items = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
print random.shuffle(items)
