if you want
//bin/sh
to become hex you can use in assembly for shell code
>>> for word in (re.findall(".{8}", binascii.hexlify("//bin/sh".encode()).decode())):
... byte = re.findall(".{2}", word)
... cmd = ""
... for index in range(len(byte)-1,-1,-1):
... cmd = cmd + byte[index]
... print("push 0x%s" % cmd)
...
push 0x69622f2f
push 0x68732f6e
side notes
binascii.hexlify converts string to binary
re.findall(".{8}", finds the words
re.findall(".{2}" , finds the bytes
range(... ,... , -1) loops through the bytes in each word backwards (endianess)
cmd = cmd + ... rebuilds the hex in the correct order