在Python 2.7及更高版本(包括python3)中工作:
result = bytearray.fromhex('deadbeef')注意:bytearray.fromhex() Python2.6中的函数似乎存在一个错误。python.org文档指出该函数接受字符串作为参数,但在应用时会引发以下错误:
>>> bytearray.fromhex('B9 01EF')Traceback (most recent call last): File "<stdin>", line 1, in <module>TypeError: fromhex() argument 1 must be unipre, not str`


