About 42,100 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 …

  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 …

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

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

  4. python - substring of an entire column in pandas dataframe

    Apr 8, 2016 · 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 …

  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 …

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

    Following previous comment, you might want to see: python: How to find a substring in another string or Basic indexing recurrences of a substring within a string (python). As this seems a …

  7. Finding a substring within a list in Python - Stack Overflow

    Dec 6, 2017 · Background: Example list: mylist = ['abc123', 'def456', 'ghi789'] I want to retrieve an element if there's a match for a substring, like abc Code: sub = 'abc' print any(sub in mystring …

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

    Jul 4, 2021 · The easiest way is probably just to split on your target word my_string="hello python world , i'm a beginner" print(my_string.split("world",1)[1]) split takes the word (or character) to …

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

  10. python find substrings based on a delimiter - Stack Overflow

    Sep 15, 2013 · I am new to Python, so I might be missing something simple. I am given an example: string = "The , world , is , a , happy , place " I have to create substrings separated by …

Refresh