Python equivalent for PHP's implode?

后端 未结 2 1542
一个人的身影
一个人的身影 2021-02-01 00:17

Is there an equivalent for PHP\'s implode in Python? I\'ve read in and split up a set of delimited words, and now I want to sort them out in random orders and print the words ou

2条回答
  •  清歌不尽
    2021-02-01 00:43

    Okay I've just found a function that does what I wanted to do;

    I read in a file with words in a format like: Jack/Jill/my/kill/name/bucket

    I then split it up using the split() method and once I had the word into an list, I concatenated the words with this method:

    concatenatedString = ' - '.join(myWordList)
    # ie: delimeter.join(list)
    

提交回复
热议问题