-1
以下织物代码返回蟒字符串比较不工作
[email protected]:~# cat fabfile.py
import fabric
def lsb_info():
ReleaseNum=fabric.api.local('lsb_release --release|awk \'{print $2}\'', capture=True)
print ReleaseNum == 12.04
print ReleaseNum
[email protected]:~# fab lsb_info
[localhost] local: lsb_release --release|awk '{print $2}'
False
12.04
Eventhough的ReleaseNum填充为12.04它不是在字符串比较等于12.04
你应该使用周围的引号:'“12.04”',否则会被视为浮动对象。 –
主要的问题放在一边,那感觉真是奇怪使用'从这样的Python脚本awk' ... – NPE
你应该学习Python第.. –