import time
from types import TracebackType
from bluetooth import *
alreadyFound=[]
def findDevs():
foundDevs=discover_devices(lookup_names=True)
for (addr,name) in foundDevs:
if addr not in alreadyFound:
print("发现蓝牙设备: | "+str(name))
print("MAC: | "+str(addr))
alreadyFound.append(addr)
while True:
findDevs()
time.sleep(5)
name里面含有中文,那么你应该使用str(name, encoding = "utf-8") ,默认是ascii方式,中文含有不能被ascii解析的编码,就会抛错误(不仅仅是字符不可见的问题)
因为没有try catch