Generating a file filled with random characters in Python
Generating a file filled with random characters in Python and printing out the elapsed time.
Output goes in tempOut.txt
#!/usr/bin/python import random import string import time start = time.time() f = open('tempOut.txt', 'w') for i in range(0,100000): line = '' for j in range(0,5000): line += str(random.choice(string.letters)) f.write(line + "n") line = '' f.close() end = time.time() print "Elapsed: " + str(end - start)
Leave a Reply