mardi 6 décembre 2016

PYTHON : How do I make my program produce a file with a random file name

import time

a = 0
amount = 1
while a < 100:
    userfile = 'random{}'.format(amount)
    file = open(userfile, 'a')
    amount += 1
    time.sleep(0.2)
    print(userfile)
    a += 1

I've made a program that creates files with a fixed file name. I'm trying to make it so the file name is a randomly generated set of letters but I don't know quite how to apply the random function to it.




Aucun commentaire:

Enregistrer un commentaire