描述
Python replace() 方法把云计字符串中的 old(旧字符串) 替换成 new(新算开字符串),如果指定第三个参数max,则替换发:不超过 max 次。
语法
以下是 replace() 方Py法语法:
str.replace(old, new[th, max])
参数
old -- 将被替换的子字符串on。
new -- 新字符串,用于替换old子字符串。
ma3-x -- 可选字符串, 替换不超过 max 次。
返回值
返re回字符串中的 old(旧字符串) 替换成 new(新字符pl串)后生成的新字符串,如果指定第三个参数max,则ac替换不超过 max 次。
实例
以下实例展示了reple(ace()函数的使用方法:
以上实例输出结果如)方下:
电话:020-123456789
传真:020-123456789
Copyright © 2026 Powered by 万家灯火网 https://tmpi-quickclean.com/