博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Python3 列表操作
阅读量:4228 次
发布时间:2019-05-26

本文共 1301 字,大约阅读时间需要 4 分钟。

list.append(obj)

# Python3>>> hello = ['h', 'e', 'l', 'l', 'o']>>> hello['h', 'e', 'l', 'l', 'o']>>> hello.append('world')>>> hello['h', 'e', 'l', 'l', 'o', 'world']

list.count(obj)

# Python3>>> hello = ['h', 'e', 'l', 'l', 'o']>>> hello.count('l')2

 list.extend(seq)

# Python3>>> hello = ['h', 'e', 'l', 'l', 'o']>>> world = ['w', 'o', 'r', 'l', 'd']>>> hello.extend(world)>>> hello['h', 'e', 'l', 'l', 'o', 'w', 'o', 'r', 'l', 'd']

list.index(obj)

# Python3>>> hello = ['h', 'e', 'l', 'l', 'o']>>> hello.index('l')2

list.insert(index, obj)

# Python3>>> hello = ['h', 'e', 'l', 'l', 'o']>>> hello.insert(2, 'world')>>> hello['h', 'e', 'world', 'l', 'l', 'o']

list.pop(index=-1)

# Python3>>> hello = ['h', 'e', 'l', 'l', 'o']>>> hello.pop()'o'>>> hello['h', 'e', 'l', 'l']>>> hello.pop(1)'e'>>> hello['h', 'l', 'l']

list.remove(obj)

# Python3>>> hello = ['h', 'e', 'l', 'l', 'o']>>> hello.remove('l')>>> hello['h', 'e', 'l', 'o']

list.reverse()

# Python3>>> hello = ['h', 'e', 'l', 'l', 'o']>>> hello.sort()>>> hello['e', 'h', 'l', 'l', 'o']>>> hello.sort(reverse=True)>>> hello['o', 'l', 'l', 'h', 'e']

list.clear()

# Python3>>> hello = ['h', 'e', 'l', 'l', 'o']>>> hello.clear()>>> hello[]

list.copy()

# Python3>>> hello = ['h', 'e', 'l', 'l', 'o']>>> aa = hello.copy()>>> aa['h', 'e', 'l', 'l', 'o']

 

 

转载地址:http://ojjqi.baihongyu.com/

你可能感兴趣的文章
JDBC Metadata, MySQL, and Oracle Recipes: A Problem-Solution Approach
查看>>
From VBA to VSTO: Is Excel's New Engine Right for You?
查看>>
Sams Teach Yourself Data Structures and Algorithms in 24 Hours
查看>>
Professional Windows Desktop and Server Hardening
查看>>
Software Estimation: Demystifying the Black Art (Best Practices
查看>>
Handbook of Research on Mobile Multimedia
查看>>
SQLite (Developer's Library)
查看>>
Measuring Information Systems Delivery Quality
查看>>
Windows 2000 Performance Guide
查看>>
Ajax And Php: Building Responsive Web Applications
查看>>
ASP.NET 2.0 Website Programming: Problem - Design - Solution
查看>>
XML in a Nutshell, Third Edition
查看>>
Excel Programming Weekend Crash Course
查看>>
BigNum Math: Implementing Cryptographic Multiple Precision Arithmetic
查看>>
Computer Networks, Fourth Edition
查看>>
Great Ideas in Computer Science with Java
查看>>
Sams Teach Yourself Network Troubleshooting in 24 Hours (2nd Edition)
查看>>
Flash Enabled: Flash Design and Development for Devices
查看>>
The Tao of Network Security Monitoring: Beyond Intrusion Detection
查看>>
Pro PHP Security
查看>>