다음과 같은 출력을 얻는 더 나은/클리너/더 짧은 방법이 있습니까?파이썬 중첩 사전 루프
for sub_dict in pl.values():
print(sub_dict['NOISE'], sub_dict['RSSI'], sub_dict['SSID_STR'], sub_dict['BSSID'])
하지만 난 얻을 :
import plistlib
pl = plistlib.readPlist('/Users/username/Documents/wifi1.plist')
n = len(pl)
count = 0
while (count < n):
print('----------------')
print(pl[count]['NOISE'])
print(pl[count]['RSSI'])
print(pl[count]['SSID_STR'])
print(pl[count]['BSSID'])
count += 1
나는 시도
Traceback (most recent call last):
File "plistread.py", line 17, in <module>
for sub_dict in pl.values():
AttributeError: 'list' object has no attribute 'values'
당신이 PL에 sub_dict에 대한'해봤가' –
티켓 이잖아
그래서, 당신은에 의해 PL 반복한다! – beoliver