通过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代码中自己使用,而斜杆却还不行。
博客通过help(sorted)查看其帮助文档,介绍了sorted函数的参数及功能。指出参数中的 / 指示前面为位置参数,此用法在部分Python版本中有,当前Python本身不支持。还提及与函数中星号用法有相似处但有差别,且星号可在代码中使用,斜杆不行。
898

被折叠的 条评论
为什么被折叠?



