About 102,000 results
Open links in new tab
  1. python - What does s.strip () do exactly? - Stack Overflow

    Dec 9, 2012 · but if we use strip() function with a argument like- s="your string goes here" s.strip("string") now as we have passed the argument as "string" this will be treated as a set of …

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

    Feb 13, 2015 · Without strip(), you can have empty keys and values: apples<tab>round, fruity things oranges<tab>round, fruity things bananas<tab> Without strip(), bananas is present in …

  3. python - How do I trim whitespace? - Stack Overflow

    Jul 26, 2009 · For whitespace on the right side, use str.rstrip: s = s.rstrip() For whitespace on the left side, use str.lstrip: s = s.lstrip() You can provide an argument to strip arbitrary characters to …

  4. list - how to use strip() in python - Stack Overflow

    Oct 8, 2015 · there are several types of strips in python, basically they strip some specified char in every line. In your case you could use lstrip or just strip: s = 'a 2hello 3fox 2hen 1dog' ' …

  5. 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) By default they …

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

    Dec 13, 2024 · 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. Python will …

  7. python - How to use text strip () function? - Stack Overflow

    Apr 4, 2017 · The reason is simple and stated in the documentation of strip: str.strip([chars]) Return a copy of the string with the leading and trailing characters removed. The chars …

  8. Python strip with \n - Stack Overflow

    Feb 19, 2012 · 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, …

  9. Strip in Python - Stack Overflow

    Sep 24, 2012 · I have a question regarding strip() in Python. I am trying to strip a semi-colon from a string, I know how to do this when the semi-colon is at the end of the string, but how would I …

  10. python - what does 'if x.strip ( )' mean? - Stack Overflow

    Jun 23, 2013 · case(1): x.strip() is empty , meaning the user didn't enter anything. In this case x.strip() is False because empty strings are "Falsey" case(2): x.strip() is not empty, meaning …

Refresh