I need to convert strings which contain the memory usage in bytes, like: 1048576 (which is 1M) into exactly that, a human-readable version, and visa-versa.
You are pretty much answering your own question in your last note, there.
In human2bytes(s), the input string -- 9.766K for example -- is split up in two parts, the number and the prefix. After the assertion (which as you correctly observe is what throws the error), the number is multiplied by the corresponding value that the prefix represents, so 9.766 * 1000 = 9766. The only way to "avoid" data loss is to accept a sufficiently precise floating-point value as input.
In order to make human2bytes accept floating-point input, you could either remove num.isdigit() from the assertion and then wrap the typecasting num = float(num) with try-except, or check it by some other means.