Python 字符串去除斜杠和空格方法
您可以使用Python的字符串操作函数来去除斜杠'/'分隔符号,并去掉空格。以下是一个示例代码:
string = 'abc/def/ghi/jkl mno/pqr/stu/vwx yz'
# 去除斜杠/分隔符号
string_without_slash = string.replace('/', '')
# 去除空格
string_without_space = string_without_slash.replace(' ', '')
print(string_without_space)
输出结果为:abcdefghijklmnopqrstuvwxyz
原文地址: https://www.cveoy.top/t/topic/bV3F 著作权归作者所有。请勿转载和采集!