from datetime import datetime
from random import randrange
from datetime import date
import random
import datetime
arr=""
def random_date(start,l):
current = start
while l >= 0:
curr = current + datetime.timedelta(month=randrange(12),days=randrange(7),hours=randrange(12),minutes=randrange(60),seconds=randrange(60))
yield curr
l-=1
startDate = datetime.datetime(2013, 9, 20,13,00,00)
arr=[]
for x in random_date(startDate,10):
arr.append(x.strftime("%d/%b/%y %H:%M:%S"))
for x in range(0,len(arr)):
print(arr[x])
vendredi 26 novembre 2021
I want to generate random month, day, hour, min, sec in python but in this code generating random month is not working. How can I do this?
Inscription à :
Publier les commentaires (Atom)
Aucun commentaire:
Enregistrer un commentaire