惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

www.infosecurity-magazine.com
www.infosecurity-magazine.com
D
DataBreaches.Net
T
Tailwind CSS Blog
M
MIT News - Artificial intelligence
Stack Overflow Blog
Stack Overflow Blog
F
Full Disclosure
V2EX - 技术
V2EX - 技术
N
News and Events Feed by Topic
Help Net Security
Help Net Security
L
LangChain Blog
Y
Y Combinator Blog
宝玉的分享
宝玉的分享
Google Online Security Blog
Google Online Security Blog
P
Proofpoint News Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
The Blog of Author Tim Ferriss
Google DeepMind News
Google DeepMind News
The Register - Security
The Register - Security
B
Blog RSS Feed
N
Netflix TechBlog - Medium
N
News | PayPal Newsroom
TaoSecurity Blog
TaoSecurity Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
V
Vulnerabilities – Threatpost
B
Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
I
Intezer
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园_首页
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
AI
AI
aimingoo的专栏
aimingoo的专栏
大猫的无限游戏
大猫的无限游戏
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Cyberwarzone
Cyberwarzone
P
Proofpoint News Feed
Google DeepMind News
Google DeepMind News
G
GRAHAM CLULEY
Vercel News
Vercel News
罗磊的独立博客
MyScale Blog
MyScale Blog
Last Week in AI
Last Week in AI
博客园 - 司徒正美
C
CERT Recently Published Vulnerability Notes
GbyAI
GbyAI
Scott Helme
Scott Helme
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
T
Troy Hunt's Blog
A
About on SuperTechFans
P
Privacy International News Feed

博客园 - YiYezc

Python的if语句 Python元组 Python列表操作 Python列表元素管理 Python字符串 Python变量 centos安装autossh bash相关 Linux的bash快捷键 Vim程序编辑器 Linux下光盘镜像生成和刻录 Linux文件系统备份dump Linux下文件压缩与打包 Linux挂载 Linux磁盘分区 Linux文件访问和日志 block、inode、superblock详解 Linux文件系统的详解 Linux的权限对于文件与目录的意义 命令与文件的查询 ctime, atime与mtime释疑 Linux下文件特殊权限 umask相关内容
Python列表管理
YiYezc · 2026-04-20 · via 博客园 - YiYezc

1.使用方法sort( )对列表元素按照字母顺序进行排序

num = ['one','two','three','four','five']

num.sort( )

执行后:num = ['five', 'four', 'one', 'three', 'two']

方法sort( )执行后,列表中的顺序已经发生改变

如果要按照字母发现排序,可以使用参数reverse=True

num = ['one','two','three','four','five']

num.sort(reverse=True )

执行后:num = ['two', 'three', 'one', 'four', 'five']

2.使用函数sorted( )对列表元素按照字母顺序临时进行排序,即列表实际顺序没有发生改变

num = ['one','two','three','four','five']

print(sorted(num))

执行打印: ['five', 'four', 'one', 'three', 'two']

3.使用方法reverse( )翻转列表顺序

num = ['one','two','three','four','five']

num.reverse( )

执行后:num = ['five', 'four', 'three', 'two', 'one']

方法sort( )执行后,列表中的顺序已经发生改变,如果想恢复,再次使用该方法即可

4.使用函数len( )获取列表的长度

num = ['one','two','three','four','five']

print(len(num))

执行得到:5