且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

相当于将R粘贴到Python

更新时间:2022-04-01 05:10:42

这非常类似于R中的Paste命令: R代码:

This very much works like Paste command in R: R code:

 words = c("Here", "I","want","to","concatenate","words","using","pipe","delimeter")
 paste(words,collapse="|")

[1]

在这里|我|想要|要连接|单词|使用|管道|厚度"

"Here|I|want|to|concatenate|words|using|pipe|delimeter"

Python:

words = ["Here", "I","want","to","concatenate","words","using","pipe","delimeter"]
"|".join(words)

结果:

在这里|我|想|要|连接|单词|使用|管道|定标"

'Here|I|want|to|concatenate|words|using|pipe|delimeter'