len()

Read(252) Label: len,

Here’s how to use len() function.

A .len()

Description:

Get the length of a sequence.

Syntax:

A.len()

Note:

The function gets the length of sequence A.

Parameters:

A

Sequence object

Return value:

An integer

Example:

 

A

 

1

=[1,2,4]

 

2

=A1.len()

3

3

=["a","b"].len()

2

4

=[]

 

5

=A4.len()

0

k. len()

Description:

Get the length of a serial byte.

Syntax:

k.len()

Note:

The function returns the length of serial byte k, which is the number of bytes in k.

Parameters:

k

A serial byte

Return value:

An integer

Example:

k(2).len()

1

k(256:2).len()

2

k(1,2,3).len()

3

T.len()

Description:

Get the number of records in a memory table.

Syntax:

T.len()

Note:

The function gets the number of records in memory table T.

Parameters:

T

A memory table

Return value:

An integer

Example:

 

A

 

1

=demo.query("select EID,NAME,GENDER from employee where EID< 10").cursor()

Return cursor of retrieved data

2

=A1.memory()

Return a memory table

3

=A2.len()

9

len()

Description:

Compute the length of a string.

Syntax:

len(s,cs)

Note:

The function computes the length of a string. The default charset is GB2312; calculate the string’s length in Unicode if parameter cs is absent.

Parameters:

s

String for which you want to compute the length

cs

Charset; can be omitted

Return value:

An integer

Example:

len("esproc")

6

len(" esproc ")

8

len("esproc",)

6

len("esproc","UTF-8")

6