Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Get a human-readable version of a file size

A function to return a human-readable size from the bytes size:

>>> human_readable(2048)
'2 kilobytes'

How can I do this?

Answer*

Cancel
2
  • An explanation would be in order. E.g., what is the idea/gist? From the Help Center: "...always explain why the solution you're presenting is appropriate and how it works". A more complete answer could also include sample input and output, what version of Python it was tested with, on what system. Commented May 7, 2024 at 12:58
  • cont' - Please respond by editing (changing) your answer, not here in comments (*** *** *** *** *** without *** *** *** *** *** "Edit:", "Update:", or similar - the answer should appear as if it was written today). Commented May 7, 2024 at 13:01