Use Python to split a string and output each token into seperate lines?


$ echo '"a1","a2","a3"'|python3 -c "import sys; print('n'.join(, sep='n');"

$ echo '"a1","a2","a3"'|python3 -c "import sys; [print(a, sep='n') for a in];"

$ echo '"a1","a2","a3"'|python3 -c "import sys,pprint; pprint.pprint('n'.join(;"

I have tried many different methods but none of them work for me.
I would like to print each token into a seperate line.

Question> How can I get the following results?


Thank you

Asked By: q0987



Split on comma instead.

Answered By: Unmitigated
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.