我正在尝试导入fabric.api
并遇到问题。我使用 pip 安装了结构,当我import fabric
在解释器中运行时它可以正常工作。
但是当我这样做时,from fabric.api import *
它会出现一个错误,提示“没有名为 api 的模块”。我正在使用 Python 2.7。我在这里缺少什么?
Python 2.7.10 (default, Oct 6 2017, 22:29:07)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> version
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'version' is not defined
>>> import fabric
>>> import fabric.api
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: …
Run Code Online (Sandbox Code Playgroud) 我有大约 1000 个文件,如果第一个字段匹配特定数字,我需要打印相应的第三个元素。由于下面的数字 7 不是常数,并且它基于前一个脚本的输出,因此当我尝试传递变量时,它失败了。
$cat ${i} | head -14 | awk '$1 == "7" {print $3}'
$Supervisor
$blah=7
$cat ${i} | head -14 | awk '$1 == "${blah}" {print $8}'
Run Code Online (Sandbox Code Playgroud)
我尝试使用其他组合来转义/扩展比较中的变量,但似乎没有一个能够扩展变量blah
。