Feb-02-2024, 07:49 AM
I guess
You can strip it. I often use
prod
has at the end of the str
a newline character.You can strip it. I often use
rstrip
to remove only on the right side of the str
whitespace. A newline character is also seen as a whitespace.delimiter = "," product_name = "Test 123" product_name_newline = "Test 123\n" print("Test without newline") print(f"{product_name}{delimiter}") print() print("Test with newline at the end of the str") print(f"{product_name_newline}{delimiter}") print() print("Test with newline at the end of the str and the prevention") print(f"{product_name_newline.rstrip()}{delimiter}") print()
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!