python绝技 — 搜寻蓝牙设备

需要安装蓝牙模块:pybluez

sudo pip install pybluez

代码

#!/usr/bin/env python
#--*--coding=utf-8--*--
#P191
#sudo pip install pybluez

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 True:
	findDevs()
	time.sleep(5)

 

python绝技 — 搜寻蓝牙设备_第1张图片

 

  

转载于:https://www.cnblogs.com/ssooking/p/6108219.html

你可能感兴趣的:(python绝技 — 搜寻蓝牙设备)