Problem in understanding Python list comprehensions

前端 未结 6 989
情书的邮戳
情书的邮戳 2021-02-03 13:42

What does the last line mean in the following code?

import pickle, urllib                                                                                                 


        
6条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-03 14:07

    join() is a string method, that works on a separator in new string

    >>> ':'.join(['ab', 'cd'])
    >>> 'ab:cd'
    

    and list comprehension is not necessary there, generator would suffice

提交回复
热议问题