【发布时间】:2020-04-28 04:40:14
【问题描述】:
给定字符串“To dance or not to dance”,让程序将所有出现的“dance”一词替换为“be”。
我的尝试,但有错误
word = "To dance or not to dance"
replaceWords = str_replace("dance","be", word)
print (replaceWords)
【问题讨论】:
-
使用字符串
replace方法stackoverflow.com/a/9452122/5180047