fork download
  1. # 给定字符串
  2. text = "Hello|Python|World"
  3.  
  4. #提取并拼接
  5. parts = text. split ("|") # 分割得到 ['Hello', 'Python', 'World']
  6. result1 = parts[ 0 ] + " " + parts[ 2 ] # 取第1个和第3个,用空格拼接
  7. print( result1 )
  8.  
Success #stdin #stdout 0.07s 14144KB
stdin
Standard input is empty
stdout
Hello World