is_end_line_break
FunctionPrivateSource
flag: bool = is_end_line_break(val_str: str)
A function used for checking whether the str ends with a line break.
The checking is implemented by
https://docs.python.org/3/library/stdtypes.html#str.splitlines
We use this function to fix the missing final line break problem of str.splitlines
.
Arguments
Requires
Argument | Type | Required | |
---|---|---|---|
val_str | str | The string that needs to be validated. |
Returns
Argument | Type | |
---|---|---|
flag | bool | If True , the validated string ends with a line break. |
Example
Check the line break
- Codes
- Results
check_line_break.py
from syncstream.base import is_end_line_break
print(is_end_line_break('no break'))
print(is_end_line_break('middle\n break'))
print(is_end_line_break('ends break\n'))
print(is_end_line_break('ends break mac\r'))
False
False
True
True