我使用python v2.7,代码如下:
maxValues = {}
for d in self.gdbs_data:
for k1,v1 in d.items():
for k2, v2 in v1.items():
for k3, v3 in v2.items():
maxValues[(k2,str(k3))] = maxValues[(k2,str(k3))] \
if (k2,str(k3)) in [i for i in maxValues.keys()] else ''
maxValues[(k2,str(k3))] = max(maxValues[(k2,str(k3))], d[k1][k2][k3])
for d in self.gdbs_data:
for k1,v1 in d.items():
for k2, v2 in v1.items():
inner = {k: v == maxValues[(k2,str(k))] for k, v in d[k1][k2].items()}
d[k1][k2] = inner
但现在我需要python v2.5,因为我需要使用这个不适用于v2.7 +的旧模块。我怎样才能将代码更改为有效并再次使用相同的工作?
错误:
Traceback (most recent call last):
File "arp\__main__.py", line 8, in <module>
from arp import ARP
File "C:\Users\G1745 IRON\Development\LL\ARP\arp\arp.py", line 124
inner = {k: v == maxValues[(k2,str(k))] for k, v in d[k1][k2].items()}
^
SyntaxError: invalid syntax
谢谢!