欢迎光临散文网 会员登陆 & 注册

20、分割字符串

2023-07-28 12:37 作者:逃跑的小可莉  | 我要投稿

my_str="itheima itcast boxuegu"
num=my_str.count("it")
new_str=my_str.replace(" ","|")
list=new_str.split("|")
print(f"字符串{my_str}中有:{num}个it字符")
print(f"字符串{my_str},被替换空格后,结果:{new_str}")
print(f"字符串{new_str},按照|分隔后,得到:{list}")


20、分割字符串的评论 (共 条)

分享到微博请遵守国家法律