About 122,000 results
Open links in new tab
  1. How do I get a substring of a string in Python? - Stack Overflow

    Aug 31, 2016 · I want to get a new string from the third character to the end of the string, e.g. myString[2:end]. If omitting the second part means 'to the end', and if you omit the first part, …

  2. python - How to get a string after a specific substring ... - Stack ...

    How can I get a string after a specific substring? For example, I want to get the string after "world" in my_string="hello python world, I'm a beginner" ...which in this case i...

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

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

  4. python - Find a substring in a string and returning the index of the ...

    Python is a "batteries included language" there's code written to do most of what you want already (whatever you want).. unless this is homework :) find returns -1 if the string cannot be found.

  5. python - How to substring a string? - Stack Overflow

    Apr 18, 2017 · 5 Extracting substrings: Strings in Python can be subscripted just like an array: s[4] = 'a'. Like in IDL, indices can be specified with slice notation i.e., two indices separated by a …

  6. python - How to find all occurrences of a substring? - Stack Overflow

    Python has string.find() and string.rfind() to get the index of a substring in a string. I'm wondering whether there is something like string.find_all() which can return all found indexes (not only the …

  7. python - Find index of last occurrence of a substring in a string ...

    Apr 5, 2020 · Python string method rindex () returns the last index where the substring str is found, or raises an exception if no such index exists, optionally restricting the search to string …

  8. How to extract a substring from a string in Python 3

    Jan 27, 2021 · I am trying to pull a substring out of a function result, but I'm having trouble figuring out the best way to strip the necessary string out using Python. Output Example: [<THIS …

  9. python - Filter pandas DataFrame by substring criteria - Stack …

    Filter pandas DataFrame by substring criteria Asked 13 years, 5 months ago Modified 2 years ago Viewed 1.6m times

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