Hi,
How do I enumerate the info within the list as a shopping list like this:
0. First WiFi info
1. Second WiFi info
...
n. Last WiFi info
my code is a mess.
TIA
Got this so far but not sure if it's the best way to go.
How do I enumerate the info within the list as a shopping list like this:
0. First WiFi info
1. Second WiFi info
...
n. Last WiFi info
my code is a mess.
TIA
import struct
nets = [(b'MOVISTAR_236E', b'\xf8\x8e\x85\xfb#o', 1, -65, 2, False),
(b'vodafoneAA3YWA', b'\x08~d\xa0-`', 11, -65, 3, False),
(b'DIRECT-25-HP ENVY 4520 series', b'\xf40\xb9\x1c\xa6&', 6, -68, 3, False),
(b'RPI', b'X\x90CLe\xd6', 11, -75, 4, False),
(b'MOVISTAR_8A3E', b'\x84\xaa\x9c\x06\x8a@', 11, -79, 3, False),
(b'MOVISTAR_236E_2.4GEXT', b"\xcc2\xe5'S1", 1, -82, 4, False),
(b'vodafone2F78', b'\xa4\x08\xf5\xef/~', 6, -83, 4, False),
(b'DIRECT-da-HP M255 LaserJet', b'\xda\x12eE\x9b\xda', 6, -89, 3, False),
(b'VM', b'\xd4{\xb0\xab|\x12', 11, -89, 3, False),
(b'DIRECT-13-EPSON-XP-4100 Series', b":\x1aR'`o", 6, -90, 3, False),
(b'MOVISTAR_78AA_EXT', b'P\xd4\xf7\xa4s\x9d', 1, -94, 4, False)
]
n = len(nets) # number of routers
m = len(nets[0]) # number of router's info
string = ''
for x in range(n):
for y in range(m):
if y == 1:
mac = "%x:%x:%x:%x:%x:%x" % struct.unpack("BBBBBB", nets[x][y])
string += mac
else:
string += str(x)
string += '. '
string += str(nets[x][y]) #.decode("utf-8"))
string += ' '
string += str(nets[x][y])
string += str(nets[x][y])
string += str(nets[x][y])
string += str(nets[x][y])
string += "\n"
print(string)
# or
for idx, val in enumerate(nets):
print("%d. %s" % (idx, val))
if __name__ == "__main__":
pass
# main()EDIT:Got this so far but not sure if it's the best way to go.
for idx, val in enumerate(nets):
name = val[0].decode("utf-8")
mac = "%x:%x:%x:%x:%x:%x" % struct.unpack("BBBBBB", val[1])
x = val[2]
dbm = val[3]
y = val[4]
bool = val[5]
print("%d. %s %s %s %s %s %s" % (idx, name, mac, x, dbm, y, bool))
