Access File In Another Directory (Python)

Viewed 33

I tried to access files with with open but the files itself located not in the same folder (since I want to access files in many different folders).

import os
path = r"C:\Users\M S I\Desktop\TA MACHINE LERANING\MODEL SKENARIO UJI 1" # here contained file "[model joblib 1 1]" until [model joblib 17 24]"
l = os.listdir(path)
for model in l:
    for Coor_X in range(1,18):
            for Coor_y in range(1,25):
                with open('model joblib ['+ str(Coor_X) +' '+ str(Coor_y) +']','rb') as f:
                    print(f)

But it keeps telling "[Errno 2] No such file or directory: 'model joblib [1 1]'"

1 Answers
with open(path, 'w') as f:
    f.write(data)
Related