python中list函数_list()函数以及Python中的示例

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函数

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值