I\'m using ls -a command to get the file names in a directory, but the output is in a single line.
ls -a
Like this:
. .. .bash_history .ss
Yes, you can easily make ls output one filename per line:
ls
ls -a | cat
Explanation: The command ls senses if the output is to a terminal or to a file or pipe and adjusts accordingly.
So, if you pipe ls -a to python it should work without any special measures.