diff options
author | Haoran S. Diao (刁浩然) <0@hairydiode.xyz> | 2023-07-05 04:53:17 -0700 |
---|---|---|
committer | Haoran S. Diao (刁浩然) <0@hairydiode.xyz> | 2023-07-05 04:53:17 -0700 |
commit | 7cd46f6842cc0e0c8279b1f1607d9ffb4acb9102 (patch) | |
tree | e4489aeaa83e3f944d70914689c4a02adb39a52f /randtest.py |
initial commit, includes venv
Diffstat (limited to 'randtest.py')
-rwxr-xr-x | randtest.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/randtest.py b/randtest.py new file mode 100755 index 0000000..1be410e --- /dev/null +++ b/randtest.py @@ -0,0 +1,30 @@ +#!/bin/python3.11 +import sys +import random +import argparse +import datetime +def main(): + #argument parsing + parg = argparse.ArgumentParser(prog='randtest', + description='generates random butes', + ) + parg.add_argument('-n', '--nbytes', type=int, + help='number of bytes to write', + default=100) + parg.add_argument('-f', '--file', + help='file name to write to', + default='test') + args = parg.parse_args() + fname = args.file + nbytes = args.nbytes + + #random + random.seed(datetime.datetime.now().microsecond) + #file open in byte mode + f = open(fname, 'wb') + #write the file + f.write(random.randbytes(nbytes)) + #close the file + f.close() + +main() |