def human2bytes(s):
    """
    >>> human2bytes('1M')
    1048576
    >>> human2bytes('1G')
    1073741824
    """
    symbols = ('B', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y')
    letter = s[-1:].strip().upper()
    num = s[:-1]
    assert num.isdigit() and letter in symbols, s
    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])
def human2bytes(s):
    """
    >>> human2bytes('1M')
    1048576
    >>> human2bytes('1G')
    1073741824
    """
    symbols = ('B', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y')
    letter = s[-1:].strip().upper()
    num = s[:-1]
    assert num.isdigit() and letter in symbols, s
    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])
def human2bytes ( s ) : symbols = ( 'B' , 'K' , 'M' , 'G' , 'T' , 'P' , 'E' , 'Z' , 'Y' ) letter = s [ - 1 : ] . strip ( ) . upper ( ) num = s [ : - 1 ] assert num . isdigit ( ) and letter in symbols , s 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 ] )
>>> human2bytes('1M')
    1048576
    >>> human2bytes('1G')
    1073741824
>>> human2bytes ( 1M ) 1048576 >>> human2bytes ( 1G ) 1073741824