About 50 results
Open links in new tab
  1. 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)

  2. 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.

  3. 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.

  4. How do I remove a substring from the end of a string (remove a …

    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 …

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

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

    Oct 8, 2015 · 3 Pointers: strip returns a new string, so you need to assign that to something. (better yet, just use a list comprehension) Iterating over a file object gives you lines, not words; …

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

  8. What is the difference between "gcc -s" and a "strip" command?

    What's the equivalent to gcc -s in terms of strip with some of its options? They both do the same thing, removing the symbols table completely. However, as @JimLewis pointed out strip …

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

    Jul 7, 2020 · The start is simple enough - it opens a file encyin.txt in read mode. It takes input - n & p - from the line, the .split() separating the two inputs. They are then classified as integers, …

  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".