我有这个代码,如果时间小于 12,我试图让它有 60% 的机会选择 3。代码:
import random
from datetime import datetime
from random import choice
am = [1, 2, 3]
pm = [1, 2]
datetime.time(datetime.now())
c =(datetime.now().strftime('%H:%M:%S %p'))
if c < '12:00:00 PM':
ch = choice(am)
else:
ch = choice(pm)
if ch == 1:
print "hello"
if ch == 2:
print "how are you?"
if ch == 3:
print "good morning"