-1

I am trying to use the path as input instead of a file name.

I tried

from pathlib import path
file_to open = Path (source/input*/in.txt)
with open ('file_to_open', 'r') as f_i:
   for line in f_i:

I could not be able to open the path. Please suggest me efficient methods to open the file using a path instead of file name.

1 Answers1

0

You can try this:

...
file_to_open = Path("source/input*/{}.txt".format(input))
...

Based on input input.

Alex Douglas
  • 191
  • 7