About 50 results
Open links in new tab
  1. python - String formatting: % vs. .format vs. f-string literal - Stack ...

    158 Assuming you're using Python's logging module, you can pass the string formatting arguments as arguments to the .debug() method rather than doing the formatting yourself: …

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

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

  3. python - Why doesn't calling a string method (such as .replace or ...

    Why doesn't calling a string method (such as .replace or .strip) modify (mutate) the string? Asked 14 years ago Modified 1 year, 4 months ago Viewed 108k times

  4. How can I copy a Python string? - Stack Overflow

    203 You don't need to copy a Python string. They are immutable, and the copy module always returns the original in such cases, as do str(), the whole string slice, and concatenating with an …

  5. string - What's the difference between str.isdigit (), isnumeric () …

    52 The Python documentation notes the difference between the three methods. str.isdigit Return true if all characters in the string are digits and there is at least one character, false otherwise. …

  6. python - Call method from string - Stack Overflow

    If I have a Python class, and would like to call a function from it depending on a variable, how would I do so? I imagined following could do it: class CallMe: # Class def App(): # Method one ...

  7. Can you call multiple methods on one line? - Stack Overflow

    Mar 2, 2015 · 24 result = text.lower().replace(string.punctuation, ' ').split(' ') With great python comes great responsibility: don't abuse this feature! The canonical maximum line length …

  8. Does Python have a string 'contains' substring method?

    Aug 9, 2010 · 573 Does Python have a string contains substring method? 99% of use cases will be covered using the keyword, in, which returns True or False:

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

  10. How do I reverse a string in Python? - Stack Overflow

    There is no built in reverse method for Python's str object. How can I reverse a string?