subprocess - Python subprocess.check_output()
问题描述
mystring = subprocess.check_output(["sudo iwlist wlan0 scan"], universal_newlines=True)
word = 'Devsign2G'
print (mystring)
print (word)
if word in str(mystring):
print ('success')
-错误信息-
回溯(最近一次通话最后): 文件“test.py”,第 52 行,在 mystring = subprocess.check_output(["sudo iwlist wlan0 scan"], universal_newlines=True) 文件“/usr/lib/python2.7/subprocess.py”,第 212 行,在 check_output 中 进程 = Popen(stdout=PIPE, *popenargs, **kwargs) 文件“/usr/lib/python2.7/subprocess.py”,第 390 行,在 __init__ 读错,写错) _execute_child 中的文件“/usr/lib/python2.7/subprocess.py”,第 1024 行 引发 child_exception OSError: [Errno 2] 没有这样的文件或目录
问题是什么?
解决方案
问题是什么?
指的OSError: [Errno 2] No such file or directory
是要执行的子进程命令。
程序参数必须按顺序单独传递,因此请更改
["sudo iwlist wlan0 scan"]
至
["sudo", "iwlist", "wlan0", "scan"]
推荐阅读
- time-series - R 中带间隙的时间序列
- firebase - 在 Firebase -Flutter 中删除子集合
- database - 在 vb.net 上清除并刷新 DataGridView
- r - R:仅当变量名称包含某个字符串时,才替换 ONE 特定行中的特定值
- silverstripe - Silver stipe 4.5 在管理员创建页面中添加 css
- python - 从 python 调用 Oracle 过程并将变量分配给 python lisr
- c# - 更改数组的索引
- sql-server - “不必要的表扫描”到底是什么意思
- windows - Spark 不再在 Windows 中运行
- r - 合并两个列不均匀的表并保留两个值