python how to print list of strings with double quotes
问题 I have a list i.e. my_list = ['a', 'b', 'c', 'd','e','f'] I want to print this out in a pipe or comma delimited format, but because some of my list objects can have commas or pipes, I would like to wrap double quotes around each object when I print i.e. the output should be "a"|"b"|"c"|"d"|"e"|"f" rather than a|b|c|d|e|f i can't use format on my version of python 回答1: Create a generator that formats each element, then unpack it and use a custom separator. If you are using Python 2, import the