有条件的设置对象的问题

时间:2018-10-25 10:09:41

标签: python-3.x

无法弄清楚为什么仅在下面的代码中为什么将输出显示为“ 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")

1 个答案:

答案 0 :(得分:0)

列表27923320中的项目27547329patches是整数,而"27923320""27547329"是字符串。这就是您想要的:

for item in patches_missing:
    if item in [27923320, 27547329]:
        print("Yes", item)
    else:
        print("No")