Skip to content

Instantly share code, notes, and snippets.

@IndhumathyChelliah
Created June 29, 2020 05:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IndhumathyChelliah/ce6dffa8a0ca87bc85d575b7a2a355ba to your computer and use it in GitHub Desktop.
Save IndhumathyChelliah/ce6dffa8a0ca87bc85d575b7a2a355ba to your computer and use it in GitHub Desktop.
s1="Hello\nworld!\n123"
print (s1.splitlines())#Output:['Hello', 'world!', '123']
print (s1.splitlines(keepends=True))#Output:['Hello\n', 'world!\n', '123']
print (s1.splitlines(True))#Output:['Hello\n', 'world!\n', '123']
s2="Hello\t\n123$"
print (s2.splitlines())#Output:['Hello\t', '123$']
print (s2.splitlines(keepends=True))#Output:['Hello\t\n', '123$']
s3="Hello\n\r123"
print (s3.splitlines())#Output:['Hello', '', '123']
print (s3.splitlines(keepends=True))#Output:['Hello\n', '\r', '123']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment