Every line of 'python strip newline' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
37 def strip_eol(line): 38 while line and line[-1] in '\r\n': 39 line = line[:-1] 40 return line
16 def strip_after_new_lines(s): 17 """Removes leading and trailing whitespaces in all but first line. 18 19 :param s: string or BibDataStringExpression 20 """ 21 if isinstance(s, BibDataStringExpression): 22 s.apply_on_strings(_strip_after_new_lines) 23 return s 24 else: 25 return _strip_after_new_lines(s)
99 def strip_blank_lines(code): 100 lines = code.splitlines(keepends=False) 101 if not lines: 102 return "" 103 out = [] 104 it = iter(lines) 105 106 line = None 107 108 for line in it: 109 if line.strip(): 110 break 111 out.append(line) 112 for line in it: 113 out.append(line) 114 for line in reversed(out): 115 if not line.strip(): 116 out.pop() 117 return "\n".join(out)