Hack Forums
[Python] Some variable mess - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] Some variable mess (/showthread.php?tid=5619862)



Some variable mess - Turnikman - May 10, 2017

Hi, i am new to python, and need some help.

import subprocess

direct_output = subprocess.check_output('find / -type f -name \"*.srt\"', shell=True)
print direct_output
Thats my code. 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
....................................................[/code][/size][/font]
Sorry for my bad English and thanks😉😉


* - Chercher - May 13, 2017

Code
import subprocess
direct_output = subprocess.check_output('find / -type f -name \"*.srt\"', shell=True).splitlines()
print direct_output[0]
print direct_output[1]