def human2bytes(s):
    """Convert from a human readable string to a size in bytes.

    Examples
    --------
    >>> human2bytes('1 MB')
    1048576
    >>> human2bytes('1 GB')
    1073741824
    """
    symbols = ('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB')

    ix = -1 if s[-2].isdigit() else -2
    letter = s[ix:].strip().upper()
    num = s[:ix].strip()
    assert letter in symbols
    num = float(num)
    prefix = {symbols[0]: 1}
    for i, s in enumerate(symbols[1:]):
        prefix[s] = 1 << (i + 1) * 10
    return int(num * prefix[letter])