替换python中的特殊字符串

米格尔·桑托斯

如何使用替换来消除字符串:“b'\n”?

由于反斜杠是一个特殊字符,我遇到了一些问题。

佩德罗

尝试使用替换方法。

>>> # The 'r' prefix indicates it is a raw string
>>> string = r"b'\n" 
>>> print(string.replace(r"b'\n'", ""))
>>> 
>>> # It will replace the pattern you wanted to a empty string

希望这可以帮助

参考:

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章