Python Forum
calculating length of string
Thread Rating:
  • 4 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
calculating length of string
#9
(Feb-27-2017, 07:15 AM)buran Wrote: however you need to take into account multiple spaces, new line, etc.

split() without arguments will do just that:
Output:
>>> x='abcd   efgh\tijkl\n  mnopq' >>> print x abcd   efgh     ijkl   mnopq >>> x.split() ['abcd', 'efgh', 'ijkl', 'mnopq']
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Reply


Messages In This Thread
calculating length of string - by desul - Feb-27-2017, 04:46 AM
RE: calculating length of string - by micseydel - Feb-27-2017, 05:28 AM
RE: calculating length of string - by desul - Feb-27-2017, 05:39 AM
RE: calculating length of string - by micseydel - Feb-27-2017, 05:41 AM
RE: calculating length of string - by desul - Feb-27-2017, 05:47 AM
RE: calculating length of string - by Larz60+ - Feb-27-2017, 07:10 AM
RE: calculating length of string - by buran - Feb-27-2017, 07:15 AM
RE: calculating length of string - by Ofnuts - Feb-27-2017, 09:56 AM
RE: calculating length of string - by desul - Feb-27-2017, 08:17 AM
RE: calculating length of string - by nilamo - Mar-22-2017, 10:00 PM
RE: calculating length of string - by ankit - Mar-23-2017, 09:00 AM
RE: calculating length of string - by ankit - Apr-12-2017, 06:36 AM
RE: calculating length of string - by ankit - May-22-2019, 10:50 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How can i limit length string? perrfect 3 14,584 Feb-10-2020, 04:52 PM
Last Post: Jendker
  python gives wrong string length and wrong character thienson30 2 3,120 Oct-15-2019, 08:54 PM
Last Post: Gribouillis
  Highlight/Underline a string | ValueError: zero length field name in format searching1 1 3,090 Jul-01-2019, 03:06 AM
Last Post: metulburr
  Python find the minimum length of string to differentiate dictionary items zydjohn 3 3,773 Mar-03-2018, 05:23 PM
Last Post: Gribouillis
  Get string length RedSkeleton007 3 4,694 Dec-04-2017, 03:19 PM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020