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 送芒果的祝福语简短
18 送给学长毕业祝福语简短