标签: list python-2.7 hex attributeerror
我有一个列表,其中填充了单个字节的十六进制值。 如果我做了像
list.encode('hex')
我得到了一个好结果。但是,如果我要求只显示部分列表
L=list[1:3] L.encode('hex')
我得到AttributeError: 'list' object has no attribute 'encode'
AttributeError: 'list' object has no attribute 'encode'
为什么会这样,我该如何避免错误?