python为带有单引号的函数提供参数
我有一个函数为其他函数提供它的参数python为带有单引号的函数提供参数,python,Python,我有一个函数为其他函数提供它的参数 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 = eu
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_lst = errata_eus_repo(str(rhel_ver), str(cv_name))
但是,如果我将变量直接发送到函数,我会得到正确的结果
我认为问题可能是为参数
errata\u eus\u repo(str(“rhel\u ver”)、str(“cv\u name”)
提供了双引号,但我仍然没有得到任何结果。有什么想法吗 引号仅用于传递文本变量名,而不是该变量包含的数据。您的问题在于如何在迭代周期中使用变量
在循环中的每次迭代中,您只初始化一个变量,
rhel\u ver
或cv\u name
。for循环应该给您一个错误。name\u rhel的原始值是多少?您的缩进是扭曲的。