Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Python中,我要替换<;短语>;母牛跳过了月亮</短语>;与<;短语>;奶牛跳过月亮</短语>;_Python_String_Replace - Fatal编程技术网

在Python中,我要替换<;短语>;母牛跳过了月亮</短语>;与<;短语>;奶牛跳过月亮</短语>;

在Python中,我要替换<;短语>;母牛跳过了月亮</短语>;与<;短语>;奶牛跳过月亮</短语>;,python,string,replace,Python,String,Replace,在Python中,我想用奶牛跳过月亮来替换奶牛跳过月亮 因此,只有在和中,空格应替换为u,这是一个下划线 不应更改所有其他位置请使用替换方法执行任务 msg1 = "the cow jumped over the moon" print(str(msg1).replace(" ","_")) 输出: the_cow_jumped_over_the_moon 这回答了你的问题吗?

在Python中,我想用
奶牛跳过月亮来替换
奶牛跳过月亮
因此,只有在
中,空格应替换为u,这是一个下划线


不应更改所有其他位置

请使用替换方法执行任务

msg1 = "the cow jumped over the moon"
print(str(msg1).replace(" ","_"))
输出:

the_cow_jumped_over_the_moon

这回答了你的问题吗?