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

    Aug 31, 2016 · And just for completeness, Java is like Python in that the String.substring () method takes start and one-past-end. This one just bit me hard, I had assumed it was length like every other …

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

    Apr 18, 2017 · 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 colon. This …

  3. How to get a string after a specific substring? - Stack Overflow

    Jul 4, 2021 · 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...

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

  5. 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 STRING …

  6. python - Count number of occurrences of a substring in a string - Stack ...

    Using the assignment operator introduced in Python 3.8, we can write a short function that uses str.find() in a loop to find overlapping instances of a target substring within a string.

  7. How to use string.replace () in python 3.x - Stack Overflow

    Feb 26, 2012 · Official doc for str.replace of Python 3 official doc: Python 3's str.replace str.replace (old, new [, count]) Return a copy of the string with all occurrences of substring old replaced by new. If the …

  8. 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 first …

  9. python - substring of an entire column in pandas dataframe - Stack …

    I have a pandas dataframe "df". In this dataframe I have multiple columns, one of which I have to substring. Lets say the column name is "col". I can run a "for" loop like below and substring the c...

  10. python - How to extract the substring between two markers ... - Stack ...

    Jan 12, 2011 · 12 In python, extracting substring form string can be done using findall method in regular expression (re) module.