如何使用替换来消除字符串:“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] 删除。
我来说两句