full_path_for_helm_values_china="/Users/julianaferreira/repos/helm-charts/deploy-global/values/services/live-china" import os for root, dirs, files in os.walk(full_path_for_helm_values_china, topdown=False): for name in files: file_path=os.path.join(root, name) file_name=os.path.join(root, name).split("/")[-1].split(".")[0] if file_name in "public-pages": print("1") print (file_name) #elif file_name in "nginx-gateway": # in check if file_name exists in string "nginx-gateway". Just "nginx" or "gateway" are true too. elif file_name == "nginx-gateway": ## == compara exacly string with file_name #elif file_name.__contains__("nginx-gateway"): # contains check if string "nginx-gateway" exists in file_name. Return true just for *"nginx-gateway"*. print("2") print (file_name) else: print("3") print (file_name)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter