About 51 results
Open links in new tab
  1. How to get the size (length) of a string in Python

    "what function can i use to calculate the size of the string"? What tutorial are you using to learn Python? Please update the question with some information on where and how you're learning Python.

  2. python - Manually compute the length of a string - Stack Overflow

    Jun 17, 2017 · A string has an attribute __len__, a function that returns the length of the string. Thus, the following solution does not use built-ins, but the calculation is trivial (without calculating operations, …

  3. Python: Get size of string in bytes - Stack Overflow

    May 5, 2025 · Does this answer your question? How can I determine the byte length of a utf-8 encoded string in Python?

  4. python - How to print a string at a fixed width? - Stack Overflow

    12 This will help to keep a fixed length when you want to print several elements at one print statement. 25s formats a string with 25 spaces, left justified by default. 5d formats an integer reserving 5 …

  5. python - How to sort a list by length of string followed by reverse ...

    Given a list of words, return a list with the same words in order of length (longest to shortest), the second sort criteria should be alphabetical. Hint: you need think of two functions. This is w...

  6. Python string formatting - limit string length, but trim string ...

    Oct 23, 2014 · I'm using Python standard logging module with custom formatter where I limit length of some fields. It uses standard % Python operator. I can apply limit for percent-formatted string like this …

  7. How to calculate the length of the string in python

    Aug 22, 2017 · How to calculate the length of the string in python Asked 8 years, 6 months ago Modified 5 years, 6 months ago Viewed 29k times

  8. python - Repeat string to certain length - Stack Overflow

    Pillmod's / Pillmuncher's code is more beautiful, but unfortunately slower than Scheirer's code, because adding to an already long string is an expensive operation (the Python runtime will have to copy the …

  9. python - Filter string data based on its string length - Stack Overflow

    Filter string data based on its string length Asked 12 years, 3 months ago Modified 3 years, 7 months ago Viewed 213k times

  10. python - How to pad a string to a fixed length with spaces - Stack …

    I've been reading an official Python book for 30 minutes trying to find out how to do this. Problem: I need to put a string in a certain length "field". For example, if the name field was 15 characters long, and …