26.27 取Unicode字符串的长整型值(little-endian序) Q: 下面这段Python3代码显示Unicode字符串"www.baidu.com"前16字节的长整数形式,2 个长整数,little-endian序: -------------------------------------------------------------------------- x = 'www.baidu.com' x = "".join([c+'\0' for c in x]).encode( 'latin-1' ).hex() y = x[:16] ''.join(map(str.__add__, y[-2::-2], y[-1::-2])) y = x[16:32] ''.join(map(str.__add__, y[-2::-2], y[-1::-2])) -------------------------------------------------------------------------- '002e007700770077' '0064006900610062' 我只会这么矬的办法,不知更好的办法是啥? A: bluerust 2020-03-07 Python3 -------------------------------------------------------------------------- import struct x = "www.baidu.com" x = bytes( x, encoding='utf-16' )[2:] [hex(struct.unpack( "