python中list函数
Python list()函数 (Python list() function)
list() function is a library function, it is used to create a list, it accepts multiple elements enclosed within brackets (because list() takes only one argument. Thus, the set of elements within brackets is considered as a single argument).
list()函数是一个库函数,用于创建列表,它接受括在方括号内的多个元素(因为list()仅接受一个参数,因此,括号内的元素集被视为单个参数)。
Syntax:
句法:
list((elements))
Parameter(s): elements – list of the elements.
参数: 元素 – 元素列表。
Return value: list – it returns a list of given elements.
返回值: list –返回给定元素的列表。
Example:
例:
Input:
students = list(("Amit shukla", "prem", "Radib", "Abhi"))
Output:
students: ['Amit shukla', 'prem', 'Radib', 'Abhi']
Python code to create a list using list() function
使用list()函数创建列表的Python代码
# python code to demonstrate example of
# list() method
# creating list
students = list(("Amit shukla", "prem", "Radib", "Abhi"))
# printing type of list() function
print("type of list() function: ", type(students))
# printing list...
print("students: ", students)
Output
输出量
type of list() function: <class 'list'>
students: ['Amit shukla', 'prem', 'Radib', 'Abhi']
翻译自: https://www.includehelp.com/python/list-function-with-example.aspx
python中list函数