Latest web development tutorials

Python len () method

description

Python len () method returns the string length.

grammar

len () method syntax:

len( str )

parameter

  • no.

return value

Returns the string length.

Examples

The following example shows len () to use:

#!/usr/bin/python
# -*- coding: UTF-8 -*-

str = "this is string example....wow!!!"

print "字符串长度: ", len(str)

Examples of the above output results are as follows:

字符串长度:  32