title: Get only the txt file you want from the folder containing the txt file - Python
body: <p>I have a folder with a <code>.txt</code> files. the name of the files are:</p>
  <pre><code>my_file1.txt
  my_file2.txt
  my_file3.txt
  my_file4.txt
  </code></pre>
  <p>In this way, only the last number is different.</p>
  <pre><code>import pickle
  
  my_list = []
  with open(&quot;/Users/users_a/Desktop/website-basic/sub_domain/sub_domain01.txt&quot;, &quot;rb&quot;) as f1, 
  open(&quot;/Users/users_a/Desktop/website-ba\
  sic/sub_domain/sub_domain02.txt&quot;, &quot;rb&quot;) as f2, open(&quot;/Users/users_a/Desktop/website- 
  basic/sub_domain/sub_domain03.txt&quot;, &quot;rb&quot;) as f3:
      my_list.append(pickle.load(f1))
      my_list.append(pickle.load(f2))
      my_list.append(pickle.load(f3))
  
  print(my_list)
  </code></pre>
  <p>In this way, I load a file and put it in the <code>my_list</code> variable to make a list and work. As the number of files to work increases, the code becomes too long and cumbersome.</p>
  <p>Is there an easier and more pythonic way to load only the desired <code>txt</code> file??</p>