我有一部分代码是这样的:
for line in response.body.split("\n"):
if line != "":
opg = int(line.split(" ")[2])
opc = int(line.split(" ")[3])
status = int(line.split(" ")[5])
if command == 'IDENTIFY':
if opg==opcodegroupr and opc==opcoder:
if status=="0":
IEEEAddrRemoteDev = line.split(" ")[6:14]
ret['success'] = "IDENTIFY: The value is %s " % (IEEEAddrRemoteDev)
self.write(tornado.escape.json_encode(ret))
self.finish()
变量 'line' 是这样的,例如:
1363011361 2459546910990453036 157 0 17 0 209 61 0 0 0 0 0 0 0 0 0 0 0 0 0 201
例如,我会采用从 6 到 14 的字段并相互“合并”以像整个字符串一样打印 IEEEAddrRemoteDev。
这是
IEEEAddrRemoteDev = line.split(" ")[6:14]
正确的方法?如果我写
print IEEEAddrRemoteDev
我什么也得不到。
这里有些不对劲...