Python script that generates blob files
Peter L Hansen
peter at engcorp.com
Fri Oct 8 10:23:54 EDT 2004
Sean Carey wrote:
> I am wondering if anyone knows of a python script or any other script
> that will generate random files with random sizes that I can specify.
Presumably using the random module would help?
length = random.randint(0, 1000)
filename = 'test'
f = open(filename, 'wb')
i = 0
while i < length:
f.write(chr(random.randint(0, 255)))
f.close()
Slight variations could simplify this... use getopt or optparse
to retrieve command line arguments if you want to specify different
filenames or length ranges etc.
-Peter
More information about the Python-list
mailing list