How do I convert a string of hexadecimal values to a list of integers?
问题 I have a long string of hexadecimal values that all looks similar to this: '\x00\x00\x00\x01\x00\x00\x00\xff\xff\x00\x00' The actual string is 1024 frames of a waveform. I want to convert these hexadecimal values to a list of integer values, such as: [0, 0, 0, 1, 0, 0, 0, 255, 255, 0, 0] How do I convert these hex values to ints? 回答1: You can use ord() in combination with map(): >>> s = '\x00\x00\x00\x01\x00\x00\x00\xff\xff\x00\x00' >>> map(ord, s) [0, 0, 0, 1, 0, 0, 0, 255, 255, 0, 0] 回答2: