我正在尝试通过 python 生成一些测试数据。(我的应用程序不在 python 中,但 python 似乎很容易生成数据)。我想通过生成活动的“时间段”来模拟员工的典型工作日。下面的函数需要生成 ' ' 之间的n
时隙数(之间有一些随机间隙看起来很自然)和(total_hrs)。start
end
total
slots = [] #list of slot == {start:<>, end:<>}
def time_slot(start, end, n, total_hrs):
# generate n non-overlapping time slot between start and end (with some random gap between to seem natural)
print (slots)
例如:
time_slot( "1/1/2013 9:00", "1/1/2013 17:00", 3, 8)
[ {start: "1/1/2013 9:00", end: "1/1/2013 10:30"}, ...., {start: "1/1/2013 14:00", end: "1/1/2013 16:44"}]
#total time == 8