在Python中从List转换为十六进制

时间:2015-02-11 03:13:10

标签: list python-2.7 hex attributeerror

我有一个列表,其中填充了单个字节的十六进制值。 如果我做了像

这样的事情
list.encode('hex')

我得到了一个好结果。但是,如果我要求只显示部分列表

L=list[1:3]
L.encode('hex')

我得到AttributeError: 'list' object has no attribute 'encode'

为什么会这样,我该如何避免错误?

0 个答案:

没有答案