可以使用Python代码来实现此操作:
string = "This is a string with spaces"
new_string = string.replace(" ", "_")
print(new_string)
This_is_a_string_with_spaces
这个代码将创建一个字符串并在其中搜索所有空格,然后使用str.replace()方法将其替换为下划线。
![]() |
好帅的苦瓜 · win7操作系统安装VS2017_win7安 ...· 4 月前 · |
![]() |
冲动的显示器 · 如何恢复删除的微信聊天记录(2024年攻略大 ...· 7 月前 · |
![]() |
睿智的荒野 · 谷歌Live ...· 10 月前 · |
![]() |
独立的柚子 · 判断鼠标是否移动到某个元素上 | 太空编程· 1 年前 · |