Python搜索蓝牙:搜索多次

import time
from bluetooth import *
alreadyFound = []
def findDevs():
    foundDevs = discover_devices(lookup_names=True)
    for (addr, name) in foundDevs:
        if addr not in alreadyFound:
            print '[*] Found Bluetooth Device: ' + str(name)
            print '[+] MAC address: ' + str(addr)
	#每搜索到一个设备将其添加到数组里
	#在搜索到的话查重
            alreadyFound.append(addr)
#通过一个while循环不断搜索
while True:
    findDevs()
    time.sleep(5)



你可能感兴趣的:(Sniff)