python 获取到的结果经过处理去掉空格
可以使用字符串的 strip() 方法去掉字符串两端的空格,或者使用 replace() 方法替换空格为其他字符,如下所示:
result = "  hello world  "
# 去掉两端空格
result = result.strip()
print(result)  # 输出:hello world
# 替换空格为其他字符
result = result.replace(" ", "")
print(result)  # 输出:helloworld
 
原文地址: https://www.cveoy.top/t/topic/bpiJ 著作权归作者所有。请勿转载和采集!