fork download
  1. text = "Hello|Python|World"
  2.  
  3. #提取并拼接
  4. parts = text. split ("|") # 分割得到 ['Hello', 'Python', 'World']
  5. result1 = parts[ 0 ] + " " + parts[ 2 ] # 取第1个和第3个,用空格拼接
  6. print( result1 )
  7. replaced = text. replace ("Python", "AI") # 将 Python 替换为 AI
  8. result2 = replaced. upper () # 转换为大写
  9. print( result2 )
Success #stdin #stdout 0.07s 14164KB
stdin
Standard input is empty
stdout
Hello World
HELLO|AI|WORLD