About 20,200,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, does it …

  2. String formatting in Python - Stack Overflow

    Use Python 3 string formatting. This is still available in earlier versions (from 2.6), but is the 'new' way of doing it in Py 3. Note you can either use positional (ordinal) arguments, or named arguments (for the …

  3. python - How to remove leading and trailing spaces from a string ...

    May 4, 2012 · How to remove leading and trailing spaces from a string? Asked 13 years, 7 months ago Modified 1 year ago Viewed 230k times

  4. python - What exactly do "u" and "r" string prefixes do, and what are ...

    There are two types of string in Python 2: the traditional str type and the newer unicode type. If you type a string literal without the u in front you get the old str type which stores 8-bit characters, and with the …

  5. How to check if the string is empty in Python? - Stack Overflow

    Does Python have something like an empty string variable where you can do: if myString == string.empty: Regardless, what's the most elegant way to check for empty string values? I find hard …

  6. string - How to get the position of a character in Python ... - Stack ...

    Feb 19, 2010 · For example in a string sentence, position of e is 1, 4, 7 (because indexing usually starts from zero). but what I find is both of the functions find() and index() returns first position of a character.

  7. python - how to find whether a string is contained in another string ...

    how to find whether a string is contained in another string Asked 15 years, 8 months ago Modified 2 years, 3 months ago Viewed 59k times

  8. python - Remove all whitespace in a string - Stack Overflow

    Oct 1, 2016 · All string characters are unicode literal in Python 3; as a consequence, since str.split() splits on all white space characters, that means it splits on unicode white space characters.

  9. python - How to change a string into uppercase? - Stack Overflow

    How can I convert a string into uppercase in Python? When I tried to research the problem, I found something about string.ascii_uppercase, but it couldn't solve the problem:

  10. python - How do I put a variable’s value inside a string (interpolate ...

    See for example How to use variables in SQL statement in Python? for proper techniques. If you just want to print (output) the string, you can prepare it this way first, or if you don't need the string for …