#replace() : 修改字符串的内容
# 语法: 字符串序列.replace(旧子串,子新串,替换次数)
# 替换次数如果超出了子串中出现的次数,表示替换所有这个子串,不写替换次数默认全部替换
str1="hello world and itcast and itheima and python"
print(str1.replace("and",'he')) #hello world he itcast he itheima he python
print(str1.replace("and",'he',5)) #hello world he itcast he itheima he python
print(str1.replace("and",'he',1)) #hello world he itcast and itheima and python
str1.replace("and",'he')
print(str1) #hello world and itcast and itheima and python
# 值未变,说明replace()有返回值
#split() : 按照指定字符分割字符串
# 语法: 字符串序列.split(分割字符,num)
# num为分割的次数,最终获得的输出数量为num+1个
# 返回的值为列表类型
str2="hello world and itcast and itheima and python"
print(str2.split("and")) #['hello world ', ' itcast ', ' itheima ', ' python']
print(str2.split("and",2)) #['hello world ', ' itcast ', ' itheima and python']
# join() :将多个字符串合并成一个新的字符串
# 语法 : 字符或子串.join(多个字符串序列)
l2=['44','55','66']
l3="--".join(l2)
print(l3) #44--55--66