Joining a list of python objects with __str__ method

前端 未结 5 703
孤城傲影
孤城傲影 2021-01-02 09:44

I\'ve already looked at this question on representing strings in Python but my question is slightly different.

Here\'s the code:

>>> class W         


        
5条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-02 09:47

    There are probably no amazing way.

    def strjoin(glue, iterable):
        return glue.join(str(s) for s in iterable)
    

提交回复
热议问题