我试图通过python访问wifi界面: 在bash中我可以使用以下
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/sbin/airport -I
-s
也可以通过。
我已尝试在python中使用以下内容:
from subprocess import call
call(['/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/sbin/airport', '-I'])
某些东西绝对不正确 - 正如我得到的回复:
Traceback (most recent call last):
File "ip3.py", line 5, in <module>
call(['/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/sbin/airport', '-I'])
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/subprocess.py", line 467, in call
return Popen(*popenargs, **kwargs).wait()
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/subprocess.py", line 741, in __init__
restore_signals, start_new_session)
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/subprocess.py", line 1356, in _execute_child
raise child_exception_type(errno_num, err_msg)
OSError: [Errno 2] No such file or directory: '/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/sbin/airport'
任何想法都会受到欢迎......我只想首先将其打印到屏幕上,保存为阵列等......
我还没有足够高的评价来回答我自己的问题,所以我会在这里说出来!
所以我是傻瓜!
from subprocess import call
call(['/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport', '-I'])
工作正常。只需删除/usr/sbin/airport
答案 0 :(得分:1)
调用第一个参数作为命令和该命令的后续参数。
在你的情况下 命令是, /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport
和命令的两个参数是,
所以,你需要把它称为,
from subprocess import call
call(['/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport' '/usr/sbin/airport', '-I'])
答案 1 :(得分:0)
试试这个
from subprocess import call
call(['/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport', '/usr/sbin/airport', '-I'])
否则它认为/usr/sbin/airport
是第一条路径的一部分。