-2
number = 240
while (number < 257):
data = format(number, 'x')
data_hex = data.decode("hex")
number = number + 1
错误消息:Python的INT诅咒在while循环
data_hex = data.decode("hex")
File "/usr/lib/python2.7/encodings/hex_codec.py", line 42, in hex_decode
output = binascii.a2b_hex(input)
TypeError: Odd-length string
我怎样才能使while循环良好,比没有放错误?
您没有包含错误。另外,如果你想拥有这个角色,使用'chr(number)'更容易。 – 2014-09-04 16:03:02
你究竟在努力完成什么?防止样本错误的微不足道的解决方案不太可能解决您的实际问题。 – 2014-09-04 16:05:21