a="abcd"
b="123"
c="789"

print ",".join([a,b,c])

结果:

abcd,123,789

  

将字符串拼接用join,Join前面的逗号是拼接时的分隔符    拼接时注意Join里面是列表

 

 

描述

Python replace() 方法把字符串中的 old(旧字符串) 替换成 new(新字符串),如果指定第三个参数max,则替换不超过 max 次。

语法

replace()方法语法:

str.replace(old, new[, max])

相关文章:

  • 2022-12-23
  • 2021-11-23
  • 2021-11-29
  • 2021-11-29
  • 2021-11-23
  • 2021-11-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-16
相关资源
相似解决方案