如何在Python中删除一个字符串中的所有空格

2022-05-07

以下示例是关于Python中包含如何在Python中删除一个字符串中的所有空格用法的示例代码,想了解如何在Python中删除一个字符串中的所有空格的具体用法?如何在Python中删除一个字符串中的所有空格怎么用?如何在Python中删除一个字符串中的所有空格使用的例子?那么可以参考以下相关源代码片段来学习它的具体使用方法。

[英]:how to remove all spaces from a string in python源码类型:Python
string = "Hello, world! Some more text here..." # Just a string
string.replace(" ", "") # Replaces all instances of " " (spaces)with "" (nothing)

# string is now "Hello,World!Somemoretexthere..."
# I hope I helped you! ;)

本文地址:https://www.itbaoku.cn/snippets/785274.html