Here's another version of @romeo's reverse implementation that handles a single input string.
import re
def get_bytes(size_string):
try:
size_string = size_string.lower().replace(',', '')
size = re.search('^(\d+)[a-z]i?b$', size_string).groups()[0]
suffix = re.search('^\d+([kmgtp])i?b$', size_string).groups()[0]
except AttributeError:
raise ValueError("Invalid Input")
shft = suffix.translate(str.maketrans('kmgtp', '12345')) + '0'
return int(size) << int(shft)