What exactly does the .join() method do?

后端 未结 9 2439
一向
一向 2020-11-22 10:54

I\'m pretty new to Python and am completely confused by .join() which I have read is the preferred method for concatenating strings.

I tried:

         


        
9条回答
  •  心在旅途
    2020-11-22 11:11

    To expand a bit more on what others are saying, if you wanted to use join to simply concatenate your two strings, you would do this:

    strid = repr(595)
    print ''.join([array.array('c', random.sample(string.ascii_letters, 20 - len(strid)))
        .tostring(), strid])
    

提交回复
热议问题