About 166,000 results
Open links in new tab
  1. 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.

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

    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 - How to use text strip () function? - Stack Overflow

    3 Just to add a few examples to Jim's answer, according to .strip() docs: Return a copy of the string with the leading and trailing characters removed. The chars argument is a string …

  4. Difference between String trim () and strip () methods

    The String.strip (), String.stripLeading (), and String.stripTrailing () methods trim white space [as determined by Character.isWhiteSpace ()] off either the front, back, or both front and back of …

  5. Is there a better way to use strip() on a list of strings? - python

    Aug 29, 2012 · list = map(str.strip, list) This will apply the function str.strip to every element in list, return a new list, and store the result back in list.

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

    Oct 1, 2016 · I want to eliminate all the whitespace from a string, on both ends, and in between words. I have this Python code: def my_handle(self): sentence = ' hello apple ' sentence.strip() …

  7. 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, …

  8. What is the purpose of readline ().strip ()? - Stack Overflow

    Jul 7, 2020 · some_string.strip() called without parameters removes all whitespace from the start and end of some_string Although python uses duck-typing, objects still have types/behaviours …

  9. Why would I use int( input().strip() ) instead of just int( input ...

    I know .strip() returns a copy of the string in which all chars have been stripped from the beginning and the end of the string. But I wonder why / if it is necessary.

  10. trim - String strip () for JavaScript? - Stack Overflow

    Jun 11, 2022 · How do I strip leading and trailing spaces from a string? For example, " dog " should become "dog".