我知道在Python 2.6中很容易实现。但是在Python 2.5中最简单的方法是什么?
x = "This is my string"
b = to_bytes(x) # I could do this easily in 2.7 using bin/ord 3+ could use b"my string"
print b
有什么建议吗?我想把x变成
00100010010101000110100001101001011100110010000001101001011100110010000001101101011110010010000001110011011101000111001001101001011011100110011100100010
echo -n 'This is my string' | xxd -b
- kev