I need to open a file from a different directory without using it's path while staying in the current directory.
When I execute the below code:
for file in os.listdir(sub_dir):
f = open(file, "r")
lines = f.readlines()
for line in lines:
line.replace("dst=", ", ")
line.replace("proto=", ", ")
line.replace("dpt=", ", ")
I get the error message FileNotFoundError: [Errno 2] No such file or directory: because it's in a sub directory.
Question: Is there an os command I can use that will locate and open the file in sub_dir?
Thanks! -let me know if this is a repeat, I searched and couldn't find one but may have missed it.