Remove
from python string
问题 When you run something through popen in Python, the results come in from the buffer with the CR-LF decimal value of a carriage return (13) at the end of each line. How do you remove this from a Python string? 回答1: You can simply do s = s.replace('\r\n', '\n') to replace all occurrences of CRNL with just NL, which seems to be what you want. 回答2: buffer = "<text from your subprocess here>\r\n" no_cr = buffer.replace("\r\n", "\n") 回答3: If they are at the end of the string(s), I would suggest to