无法弄清楚为什么仅在下面的代码中为什么将输出显示为“ No”。 它不应该为这两个设置值打印“是”
import re
import subprocess
from plumbum import local, cmd
s = subprocess.check_output(["opatch", "lsinventory"])
output = s.decode("utf-8")
patches = [27923320, 27547329, 21171382, 21463894, 18961555, 28432129]
patches_found = set(re.findall(r'\b(?:%s)\b' % '|'.join(map(str, patches)), output))
patches_missing = set(map(str, patches)) - patches_found
for item in patches_missing:
if item in ["27923320", "27547329"]:
print("Yes", item)
else:
print("No")
答案 0 :(得分:0)
列表27923320
中的项目27547329
和patches
是整数,而"27923320"
和"27547329"
是字符串。这就是您想要的:
for item in patches_missing:
if item in [27923320, 27547329]:
print("Yes", item)
else:
print("No")