[英]instance is not matching with filename under if statment
I have got a list of instance id calling function: instance_ID = get_instance_id()
.我有一个调用 function:
instance_ID = get_instance_id()
的实例 ID 列表。 howver when i compare instanceid with file name it matching nothing though I can see it matching when i run: #print("{} - {}".format(instance,filename))
但是,当我将 instanceid 与文件名进行比较时,它什么都不匹配,尽管我在运行时可以看到它匹配:
#print("{} - {}".format(instance,filename))
def main():
instance_ID = get_instance_id()
#print(instance_ID)
os.chdir(f'{basedir}/../config/')
config_dir = Path()
for file in config_dir.glob(f"**/*.yaml"):
for instance in instance_ID:
filename = file.stem
#print("{} - {}".format(instance,filename))
if instance == filename:
print(instance)
if __name__ == '__main__':
main()
But just found the issue.there was a space in the csv file from where I am taking those instance ID.That caused the issue.after i instance.strip() problem resolved但刚刚发现了问题。csv 文件中有一个空格,我从中获取这些实例 ID。这导致了问题。在我解决了 instance.strip() 问题后
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.