Advertisement
bob_f

create_random_datafile.py

Feb 17th, 2024
684
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  1.  
  2. import os
  3. import secrets
  4. import string
  5.  
  6. def get_temp_file_name(a_file_name_length: int) -> str:
  7.     return ''.join(secrets.choice(string.ascii_lowercase + string.digits) for _ in range(a_file_name_length))
  8.  
  9. def generate_temp_file(a_file_name: str, a_length: int):
  10.     with open(a_file_name, 'wb') as OUTFILE:
  11.         OUTFILE.write(os.urandom(a_length))
  12.  
  13. generate_temp_file(get_temp_file_name(8), pow(1024, 1))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement