2014-10-06 87 views
0
import bluetooth 

print("performing inquiry...") 

nearby_devices = bluetooth.discover_devices(lookup_names = True) 

print("found %d devices" % len(nearby_devices)) 

for addr, name in nearby_devices: 
print(" %s - %s" % (addr, name)) 

使用蓝牙搜索设备我在这个语言的初学者,我得到这个错误信息: runfile('C:/Users/Welcome/.xy/startups/one.py',wdir=r'C:/Users/Welcome/.xy/startups'在Python 2.7

请帮助我。

+0

混合”请帮助我。 – 2014-10-06 11:57:05

+1

你需要做正确的indentatiton。 for循环打印命令后必须选项卡 – 2014-10-06 11:58:05

回答

0

作为@Ozan Dniz评论说,你应该@Karikeswar Das纠正最后一行的缩进。

for addr, name in nearby_devices: 
    print(" %s - %s" % (addr, name)) # indented lines "belong" to loop 

您的代码应使用纯SPACE字符缩进,没有任何标签 -s或EM一起