20、分割字符串
my_str="itheima itcast boxuegu"
num=my_str.count("it")
new_str=my_str.replace(" ","|")
list=new_str.split("|")
print(f"字符串{my_str}中有:{num}個(gè)it字符")
print(f"字符串{my_str},被替換空格后,結(jié)果:{new_str}")
print(f"字符串{new_str},按照|分隔后,得到:{list}")
標(biāo)簽: