2024-04-26 09:52:09 发布
网友
例如:
输入:
{'match_all':{}}
输出:
{'"match_all"':{}}
有没有正则表达式可以这样做
我知道我可以遍历字符串,每当我遇到一个键时,用“'”后跟“'”替换它的每一边;不过,我想知道你们中是否有人知道一种更为恶作剧的方法
为什么不尝试使用以下方法:https://www.tutorialspoint.com/python/string_replace.htm并尝试替换“for”和第二个“for”
str = "this is string example....wow!!! this is really string" print str.replace("is", "was") print str.replace("is", "was", 3)
输出返回:
thwas was string example....wow!!! thwas was really string thwas was string example....wow!!! thwas is really string
thwas was string example....wow!!! thwas was really string
thwas was string example....wow!!! thwas is really string
print str.replace("'", "'"") print str.replace("'", ""'", 1)
根据需要使用''以避免错误
为什么不尝试使用以下方法:https://www.tutorialspoint.com/python/string_replace.htm并尝试替换“for”和第二个“for”
输出返回:
根据需要使用''以避免错误
相关问题 更多 >
编程相关推荐