Free tools Windows power users keep installed
One-click scans. No signup required.
Use Python’s built-in len() function: len(my_string). For a Python str, the result is the number of Unicode code points in the string—not its encoded byte count or necessarily the number of symbols a person sees.
Get a string’s length with len()
Pass the string to the built-in function. It returns an integer.
text = "Python"
print(len(text)) # 6
You can also pass a string literal directly:
len("Python") # 6
This is Python’s documented string-length operation; use len(my_string), not my_string.len(). The Python 3.14.8 built-in types documentation defines len(s) as the length operation.
What does the length count?
For a Python str, len() counts Unicode code points. Python describes strings as immutable sequences of Unicode code points in its built-in types documentation; the Python 3.14.7 Unicode objects and codecs documentation also describes Unicode length in code points.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minute#1 Best Overall
A code point is not always one user-perceived character. An accented letter may be stored as one precomposed code point or as a base letter plus a combining mark. Likewise, an emoji displayed as one symbol may be made from multiple code points. So len(text) answers how many code points are in the Python string, not necessarily how many visible symbols a person would count.
Count encoded bytes instead
If you need the number of bytes in a particular encoding, encode the string first and measure the resulting bytes object. For UTF-8:
Rank #2
text = "Python"
byte_count = len(text.encode("utf-8"))
This counts the bytes in the UTF-8 representation, which is a different measurement from the code-point count of the original str. For user-perceived characters, neither measurement necessarily gives the desired count; that requires higher-level text segmentation into grapheme clusters.
Quick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
Recommended Free Tools




