1
我有一個Python腳本,我的家人用它在我們的媒體中心播放隨機孩子的電視節目。我的妻子告訴我,該節目似乎贊同相同的節目選擇。有沒有辦法讓它更隨機,以便從一些不同的選項中選擇?用Python腳本打開一個隨機文件
在此先感謝。
以下是我目前正在使用:
import glob,random,os
files = glob.glob("D:\Recorded TV\Bubble Guppies*.wtv")
files.extend(glob.glob("D:\Recorded TV\Doc McStuffins*.wtv"))
files.extend(glob.glob("D:\Recorded TV\Mickey Mouse Clubhouse*.wtv"))
files.extend(glob.glob("D:\Recorded TV\Octonauts*.wtv"))
files.extend(glob.glob("D:\Recorded TV\Team Umizoomi*.wtv"))
files.extend(glob.glob("D:\Recorded TV\Jake and the Never Land Pirates*.wtv"))
files.extend(glob.glob("D:\Recorded TV\PAW Patrol*.wtv"))
files.extend(glob.glob("D:\Recorded TV\Yo Gabba Gabba*.wtv"))
files.extend(glob.glob("D:\Recorded TV\Henry Hugglemonster*.wtv"))
files.extend(glob.glob("D:\Recorded TV\Wallykazam*.wtv"))
files.extend(glob.glob("D:\Recorded TV\Dora the Explorer*.wtv"))
files.extend(glob.glob("D:\Recorded TV\Jungle Junction*.wtv"))
files.extend(glob.glob("D:\Recorded TV\Little Einstein*.wtv"))
files.extend(glob.glob("D:\Recorded TV\The Wonder Pets*.wtv"))
files.extend(glob.glob("D:\Recorded TV\WordWorld*.wtv"))
file = random.choice(files)
print "Opening file %s..." % file
cmd = "rundll32 url.dll,FileProtocolHandler \"" + file + "\""
os.system(cmd)
在你的'random.choice()'調用之前嘗試'random.seed()'。這將根據系統時間(僞隨機值)播種「隨機」流。 – CoryKramer
這看起來像是一個概率問題,而不是其他任何事情。我的猜測是某些節目比其他節目有更多的節目?或者更頻繁地選擇同一集? –
這裏也可能有心理問題,例如確認偏見。您可以考慮保留最近播放的劇集(甚至是節目)的清單,並在重新挑選時放棄它們。 – jonrsharpe