从Python中的字符串中删除反斜杠 [英] Removing backslashes from a string in Python

查看:2675
本文介绍了从Python中的字符串中删除反斜杠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从Python中的字符串中删除所有的反斜杠?

How do I remove all the backslashes from a string in Python?

这对我来说不起作用:

result = result.replace("\\", result)

我需要将结果作为原始字符串处理吗?

Do I need to treat result as a raw string?

推荐答案

您的代码是用来替换每个实例'\'结果。您是否尝试将其更改为 result.replace(\\,)

Your code is saying to replace each instance of '\' with result. Have you tried changing it to result.replace("\\", "") ?

这篇关于从Python中的字符串中删除反斜杠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆