我有这个代码:
/server/frontend/wsn.py
Line 866:
netid = hextransform(int(nid), 16)
Line 156:
def hextransform(data, length):
data = hex(data)[2:]
assert(len(data) <= length)
# zero-padding
data = ('0' * (length - len(data))) + data
# Swap 'bytes' in the network ID
data = list(data)
for i in range(0, length, 2):
tmp = data[i]
data[i] = data[i + 1]
data[i + 1] = tmp
# Reverse the whole string (TODO: CHECK)
data.reverse()
#data = "".join(data)
return data
我的问题是当我有一个nid = 15579202759033880576
例子时。是不是太长了?
我从 Tornado 收到的错误是这样的:
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/tornado/web.py", line 988, in _execute
getattr(self, self.request.method.lower())(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/tornado/web.py", line 1739, in wrapper
return method(self, *args, **kwargs)
File "./wsn.py", line 866, in get
netid = hextransform(int(nid), 16)
File "./wsn.py", line 158, in hextransform
assert(len(data) <= length)
AssertionError
但netid
在十六进制中是 0xd834725e00000000
and len(nid) = 16
。
我不知道问题是什么。