directory
- An introduction to the Len function in Python
- The len function is used in Python
- Guess you like it
Recommended path for learning Python: Python Learning Directory >> Python Basics
After print, len and type are probably the most frequently used apis in Python.
An introduction to the Len function in Python
The length (item number) argument to return an object can be a sequence (e.g., string STR **, tuple tuple, list list) or a set (e.g., dict**, set, or frozenset frozenset) with the following syntax:
Parameter: s - Object or sequence (such as string STR, tuple tuple, list list) or set (such as dictionary dict, set set, or frozen set) Return value: Return length (>=0) len(s)Copy the code
The len function is used in Python
#! Usr /bin/env python # -* -coding :utf-8 _*- "" www.codersrc.com @file :Python len function. py @time :2021/04/29 07:37 @motto: A thousand miles without a small step, a river without a small stream, the wonderful life of the program needs to be accumulated unrelentingly! "" "a = (# 6) tuple list b = [1, 2, 3, 4] # c = range (0, 10) # range d = {' name ':' lisi ', 'age: 14} # dictionary e =' helloworld ' # # string f = {1, 2, 3, 4, 5} collection g = frozenset freezing (,2,3,4,5,8 [1]) # set print (" a: ", len) (a) print (" b: ", len (b)) print (" c: ", len (c)) Print (" d: ", len (d)) print (" e: ", len (e)) print (" f: ", len (f)), ' ' 'output: a: b: 4 c: d: 2 e: 10 f: 5' ' 'Copy the code
3.Guess you like
- The Python for loop
- The Python string
- The Python list
- The Python tuple tuple
- Python dictionary dict
- Python conditional derivations
- Python list derivations
- Python dictionary derivations
- Python function declarations and calls
- Python variable argument *argc/**kargcs
- Python anonymous function lambda
- Python return logic determines expressions
- Python string/list/tuple/dictionary conversions
- Python local and global variables
- The Python type function is different from the isinstance function
- Python is differs from ==
- Python mutable and immutable data types
- Shallow and deep copies of Python
Len functions in Python
This article is published by the blog – Ape Say Programming Ape Say programming!