I am using something like:
tmp=fileA.read(4)
outfile.write(tmp)
But there comes the problem if fileA is reaching the end and only 2 bytes is left. In that case, the content of tmp will be
xx (Not XXXX any more)
And I would like to compensate the missing x by 0, so it can be like
xx00
When I write into the file outfile
THe question is, I know I can use function
len(tmp)
to know how many 0 I need to add, is there any easy way to do this adding operation?
I can think of
if len(tmp) == 2 : tmp = tmp + "00"
elif len(tmp) == 3: .......
But this is some kind of "stupid" method.
Is there a way to do it like:
tmp << (4-len(tmp)) | "0000"
Thanks for your help