Skip to content

Instantly share code, notes, and snippets.

@shanehh
Created March 22, 2021 12:28
Show Gist options
  • Save shanehh/1dc5f0575439248aa7cb55f9f9e27701 to your computer and use it in GitHub Desktop.
Save shanehh/1dc5f0575439248aa7cb55f9f9e27701 to your computer and use it in GitHub Desktop.
Sometimes you need to create a file of a specified size...
def create_any_MB_file(filepath, n):
with open(filepath, 'wb+') as f:
for _ in range(2**20 * n):
f.write(bytes(1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment