可以使用Python代码来实现此操作:
string = "This is a string with spaces"
new_string = string.replace(" ", "_")
print(new_string)
This_is_a_string_with_spaces
这个代码将创建一个字符串并在其中搜索所有空格,然后使用str.replace()方法将其替换为下划线。
|
|
暴走的黄豆 · 【iOS界面开发】UIWindow屏幕旋转自 ...· 9 月前 · |
|
|
儒雅的打火机 · android studio文字超链接 - ...· 1 年前 · |
|
|
博学的甘蔗 · LocalDateTime常用方法总结,总有 ...· 2 年前 · |
|
|
爱喝酒的火车 · 将vs+Qt的工程从windows平台移植到 ...· 2 年前 · |
|
|
豪爽的篮球 · 如何用Unity在安卓上使用流媒体资产的文件?· 2 年前 · |