title: how to get list of files from a directory into text file using python
body: <p>This question is how to get list of files from a directory into text file using python. </p>
  
  <p>Result in the text file should exactly be like this:</p>
  
  <pre><code>E:\AA\a.jpg
  E:\AA\b.jpg
  ...
  </code></pre>
  
  <p>How to correct the code below:</p>
  
  <pre><code>WD = "E:\\AA"
  import glob
  files = glob.glob ('*.jpg')
  with open ('infiles.txt', 'w') as in_files:
      in_files.write(files +'\n')
  </code></pre>