0

I am new to python, and need some help. This is my code:

import subprocess

direct_output = subprocess.check_output('find / -type f -name \"*.srt\"', shell=True)
print direct_output

I have output like this:

/path/to/my/code/name.srt

/path/to/my/code/other_name.srt

But I want to list this outputs one by one. Something like: print print direct_output[1]

output:

/path/to/my/code/other_name.srt
SiHa
  • 7,830
  • 13
  • 34
  • 43
  • 3
    Possible duplicate of [python loop over subprocess.check\_output by line](http://stackoverflow.com/questions/18244091/python-loop-over-subprocess-check-output-by-line) – SiHa May 11 '17 at 11:40
  • Why are you not using a python function (glob?) for this task? Do you really want a different process? – Reut Sharabani May 11 '17 at 11:57
  • Possible duplicate of [Find all files in a directory with extension .txt in Python](http://stackoverflow.com/questions/3964681/find-all-files-in-a-directory-with-extension-txt-in-python) – Reut Sharabani May 11 '17 at 11:58
  • Read http://www.pythonforbeginners.com/lists/python-lists-cheat-sheet – stovfl May 11 '17 at 12:00

0 Answers0