使用RF写一下代码:获取当前时间结束时间为当前时间+随机时长随机时长必须大于等于1h小于等于8h时间需要加上小时
import datetime import random
current_time = datetime.datetime.now() random_hours = random.randint(1, 8)
end_time = current_time + datetime.timedelta(hours=random_hours)
print("Current Time:", current_time.strftime("%Y-%m-%d %H:%M:%S")) print("End Time:", end_time.strftime("%Y-%m-%d %H:%M:%S"))
原文地址: http://www.cveoy.top/t/topic/iC8Y 著作权归作者所有。请勿转载和采集!