Java String.getBytes() 和 Python 字符串之间的行为完全相同 -> 字节?
在我的Java代码中,我有以下代码片段:
String secret = "secret";
byte[] thebytes = secret.getBytes();
我希望在python中具有完全相同的结果。我该怎么做?
secret = 'secret'
thebytes = ??? ??? ???
谢谢。
编辑:
此外,拥有Python 2.x和3.x的解决方案将很有趣。