list()函数以及Python中的示例
Pythonlist()功能
list()函数是一个库函数,它用于创建列表,它接受括在方括号内的多个元素(因为list()仅接受一个论点。因此,方括号内的元素集被视为单个参数)。
语法:
list((elements))
Parameter(s):elements–元素列表。
返回值:list–返回给定元素的列表。
示例
Input:
students = list(("Amit shukla", "prem", "Radib", "Abhi"))
Output:
students: ['Amit shukla', 'prem', 'Radib', 'Abhi']使用以下代码创建列表的Python代码list()功能
#python代码演示示例
# list() method
#创建列表
students = list(("Amit shukla", "prem", "Radib", "Abhi"))
# printing type of list() function
print("type of list() function: ", type(students))
#打印列表...
print("students: ", students)输出结果
type of list() function: <class 'list'> students: ['Amit shukla', 'prem', 'Radib', 'Abhi']
热门推荐
7 简短的二胎祝福语
10 简短霸气女儿生日 祝福语
11 祝福语高考小众诗句简短
12 元旦祝福语20秒简短
13 老师过年祝福语大全 简短
14 一生祝福语简短
15 产检祝福语简短霸气
16 朋友店开张祝福语简短
17 生日爱情祝福语大全简短
18 朋友女儿生日祝福语 简短