共計 209 個字符,預計需要花費 1 分鐘才能閱讀完成。
Python 中可以使用 str.replace()
方法來替換字符串中的指定字符。以下是一個示例:
string = "Hello, World!"
new_string = string.replace(",", "")
print(new_string) # Output: Hello World!
在上面的示例中,我們使用 replace(",", "")
來將字符串中的逗號替換為空字符串,從而去掉了指定的字符。
丸趣 TV 網 – 提供最優質的資源集合!
正文完