About 24,200,000 results
Open links in new tab
  1. 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 …

  2. How do I append one string to another in Python?

    Dec 14, 2010 · For handling multiple strings in a list, see How to concatenate (join) items in a list to a single string. See How do I put a variable’s value inside a string (interpolate it into the string)? if …

  3. Is python += string concatenation bad practice? - Stack Overflow

    Sep 24, 2016 · When joining strings Python only has to allocate new memory for the final string, which is much more efficient, but could take longer to compute. Also, because strings are immutable it's often …

  4. python - How do I pad a string with zeros? - Stack Overflow

    How do I pad a numeric string with zeroes to the left, so that the string has a specific length?

  5. 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 12 months ago Viewed 230k times

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

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

  8. How do I escape curly-brace ( {}) characters characters in a string ...

    You can avoid having to double the curly brackets by using f-strings ONLY for the parts of the string where you want the f-magic to apply, and use regular (dumb) strings for everything that is literal and …

  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. python - How to concatenate (join) items in a list to a single string ...

    Sep 17, 2012 · For handling a few strings in separate variables, see How do I append one string to another in Python?. For the opposite process - creating a list from a string - see How do I split a …