字符串:替换字符串中的单词

2024-06-26 14:47:54 发布

您现在位置:Python中文网/ 问答频道 /正文

给定字符串“跳舞还是不跳舞”,让程序用“be”替换“dance”一词的所有出现

我的尝试失败了

    word = "To dance or not to dance"
    replaceWords = str_replace("dance","be", word)
    print (replaceWords)

Tags: orto字符串程序notbereplaceword