鱼C论坛

 找回密码
 立即注册
查看: 2464|回复: 9

[已解决]关于列表的sort方法

[复制链接]
回帖奖励 5 鱼币 回复本帖可获得 1 鱼币奖励! 每人限 1 次(中奖概率 50%)
发表于 2019-8-31 10:34:22 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
在Python的doc帮助中,sort似乎有三个以上的函数,并未有reverse这个参数:sort(sort_criteria, charset, search_criterion[, ...]),原谅我有道翻译看不懂,请大佬们解释一下这三个参数的作用分别是干什么的。。。
翻译结果:
  sort命令是搜索的变体,具有对结果排序的语义。返回的数据包含一个以空格分隔的匹配消息编号列表。
  Sort在search_criterion参数之前有两个参数;括号中的sort_criteria列表和搜索字符集。注意,与搜索不同,搜索字符集参数是强制性的。还有一个uid排序命令,它对应于uid搜索对应于搜索的排序方式。sort命令首先使用charset参数在搜索条件中解释字符串,搜索邮箱中匹配给定搜索条件的消息。然后返回匹配消息的数量。
  这是一个IMAP4rev1扩展命令。
英语版:
The sort command is a variant of search with sorting semantics for the results. Returned data contains a space separated list of matching message numbers.
Sort has two arguments before the search_criterion argument(s); a parenthesized list of sort_criteria, and the searching charset. Note that unlike search, the searching charset argument is mandatory. There is also a uid sort command which corresponds to sort the way that uid search corresponds to search. The sort command first searches the mailbox for messages that match the given searching criteria using the charset argument for the interpretation of strings in the searching criteria. It then returns the numbers of matching messages.
This is an IMAP4rev1 extension command
最佳答案
2019-8-31 10:35:55
你应该点下面那个list method首先知道你要查的是啥
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2019-8-31 10:35:27 | 显示全部楼层
sort(sort_criteria, charset, search_criterion[, ...])???没见过
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-8-31 10:35:55 | 显示全部楼层    本楼为最佳答案   
你应该点下面那个list method首先知道你要查的是啥
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-8-31 10:39:09 | 显示全部楼层

回帖奖励 +1 鱼币

sort(sort_criteria, charset, search_criterion[, ...]) 完全不是 list.sort() 的原型
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-8-31 11:00:25 | 显示全部楼层
你查询的是Python的BIF,但你说的那个sort()是列表对象的方法
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-8-31 11:02:11 | 显示全部楼层
尝试这样:
  1. >>> empty = []
  2. >>> help(empty.sort)
  3. Help on built-in function sort:

  4. sort(*, key=None, reverse=False) method of builtins.list instance
  5.     Stable sort *IN PLACE*.

  6. >>>
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-8-31 11:02:59 | 显示全部楼层

回帖奖励 +1 鱼币

这中奖概率也太低了吧!
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-8-31 12:48:05 | 显示全部楼层
@_2_ 不用这么麻烦,直接 help(list.sort)
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 1 反对 0

使用道具 举报

 楼主| 发表于 2019-8-31 12:54:36 | 显示全部楼层
塔利班 发表于 2019-8-31 10:35
你应该点下面那个list method首先知道你要查的是啥

原来如此,你说的这个才是列表方法的sort
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 1 小时前 | 显示全部楼层
学习了
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2026-7-18 17:53

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表