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