可以使用Python代码来实现此操作:
string = "This is a string with spaces"
new_string = string.replace(" ", "_")
print(new_string)
This_is_a_string_with_spaces
这个代码将创建一个字符串并在其中搜索所有空格,然后使用str.replace()方法将其替换为下划线。
![]() |
睿智的柿子 · prometheus.yml ...· 11 月前 · |
![]() |
月球上的镜子 · PSSession 简介 - ...· 1 年前 · |
![]() |
傲视众生的枇杷 · 进程生成器导致error2无法找到指定的路径 ...· 1 年前 · |
![]() |
粗眉毛的松树 · html/css使div元素不随网页窗口大小 ...· 1 年前 · |
![]() |
怕老婆的四季豆 · "CASE" statement ...· 1 年前 · |