About 50 results
Open links in new tab
  1. python - How do I trim whitespace? - Stack Overflow

    Jul 26, 2009 · Is there a Python function that will trim whitespace (spaces and tabs) from a string? So that given input " \t example string\t " becomes "example string".

  2. string - strip () vs lstrip () vs rstrip () in Python - Stack Overflow

    -1 lstrip, rstrip and strip remove characters from the left, right and both ends of a string respectively. By default they remove whitespace characters (space, tabs, linebreaks, etc)

  3. python - Remove all whitespace in a string - Stack Overflow

    Oct 1, 2016 · All string characters are unicode literal in Python 3; as a consequence, since str.split() splits on all white space characters, that means it splits on unicode white space characters.

  4. String.strip() in Python - Stack Overflow

    Without strip (), bananas is present in the dictionary but with an empty string as value. With strip (), this code will throw an exception because it strips the tab of the banana line.

  5. Python strip with \n - Stack Overflow

    Feb 19, 2012 · 37 The strip() method removes whitespace by default, so there is no need to call it with parameters like '\t' or '\n'. However, strings in Python are immutable and can't be modified, i.e. the …

  6. python - How to remove leading and trailing spaces from a string ...

    May 4, 2012 · strip([chars]): You can pass in optional characters to strip([chars]) method. Python will look for occurrences of these characters and trim the given string accordingly.

  7. Remove specific characters from a string in Python

    Oct 15, 2010 · I'm trying to remove specific characters from a string using Python. This is the code I'm using right now. Unfortunately, it appears to do nothing to the string. for char in line: if char in &q...

  8. python - How do I remove a substring from the end of a string …

    926 strip doesn't mean "remove this substring". x.strip(y) treats y as a set of characters and strips any characters in that set from both ends of x. On Python 3.9 and newer you can use the removeprefix …

  9. Python strip() multiple characters? - Stack Overflow

    Oct 10, 2010 · 10 strip only strips characters from the very front and back of the string. To delete a list of characters, you could use the string's translate method:

  10. python - How to strip all whitespace from string - Stack Overflow

    How do I strip all the spaces in a python string? For example, I want a string like strip my spaces to be turned into stripmyspaces, but I cannot seem to accomplish that with strip (): >>> '