python中sorted是啥意思_Python中sorted的参数中的斜杆是什么意思?

通过help(sorted)查看sorted的帮助文档,显示如下:

```

Help on built-in function sorted in module builtins:

sorted(iterable, /, *, key=None, reverse=False)

Return a new list containing all items from the iterable in ascending order.

A custom key function can be supplied to customize the sort order, and the

reverse flag can be set to request the result in descending order.

```

这里的sorted参数中的 / 不代表任何参数,它指示前面的都是位置参数,没有关键词参数,不过这种用法现在的Python本身并不支持,而是某些混合支持的Python版本中的用法。

在[《Python中sorted(iterable, *, key=None, reverse=False)函数参数定义中的独立星号(*)的含义》](https://blog.csdn.net/LaoYuanPython/article/details/94406075)说明了这个函数中星号的用法,这二者的用法有点相似的味道,但还是有差别,并且星号的使用现在开发者可以在Python代码中自己使用,而斜杆却还不行。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值