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']
热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短