我有一个函数,它为其他函数提供其参数
def errata_eus_repo(rhel_ver, cv_name):
rhel_check = "Red Hat Enterprise Linux Extended Update Support" + " " + rhel_ver
cv_name_errat = []
for eus_repo in erra_eus_repo:
errata = eus_repo[0]
product = eus_repo[1]
if product == rhel_check:
cv_name_errat.extend([cv_name, errata])
return cv_name_errat
def filter_ver(rhel_ver):
regex = re.compile('\d{1}\.\d{1}')
if not regex.match(rhel_ver):
return False
return True
for cv_rhel_ver in name_rhel:
if not filter_ver(cv_rhel_ver):
cv_name = str(cv_rhel_ver)
if filter_ver(str(cv_rhel_ver)):
rhel_ver = str(cv_rhel_ver)
errata_eus_lst = errata_eus_repo(str(rhel_ver), str(cv_name))
print(errata_eus_lst)当我调用errata_eus_repo时,我得不到结果
errata_eus_lst = errata_eus_repo(str(rhel_ver), str(cv_name))但是,如果我将变量直接发送给函数,我会得到正确的结果。
我认为问题可能是为参数errata_eus_repo(str("rhel_ver"), str("cv_name"))提供双引号,但我仍然没有得到任何结果。有什么想法吗?
发布于 2017-07-10 05:17:38
引号仅用于传递文字变量名,而不是该变量包含的数据。您的问题在于如何在迭代周期中使用变量。
在循环中的每个迭代中,您只需初始化一个变量,即rhel_ver或cv_name。for循环应该会给您一个错误。
https://stackoverflow.com/questions/45000076
复制相似问题