import math


def humanize_size(n):
  """Convert file size in bytes to a friendly human readable form.

  Args:
    n: int.
      Size in bytes.

  Returns:
    str. Human-friendly size.

  #### Examples

  ```python
  humanize_size(1024)
  ## '1 KB'
  ```
  """
  exp = 0
  b = 1024
  u = 'B'
  pre = [''] + [p + '' for p in 'KMGTPEZY']
  r, f = min(int(math.log(max(n * b ** exp, 1), b)),
             len(pre) - 1), '{:,.%if} %s%s'
  h = (f % (abs(r % (-r - 1)), pre[r], u)).format(n * b ** exp / b ** float(r))
  return h