`
haoningabc
  • 浏览: 1466650 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

python数据结构

阅读更多
help(int)
help(str)
----------list----------
#!/usr/bin/python
# Filename: using_list.py

# This is my shopping list
shoplist = ['apple', 'mango', 'carrot', 'banana']

print 'I have', len(shoplist),'items to purchase.'

print 'These items are:', # Notice the comma at end of the line
for item in shoplist:
    print item,

print '\nI also have to buy rice.'
shoplist.append('rice')
print 'My shopping list is now', shoplist

print 'I will sort my list now'
shoplist.sort()
print 'Sorted shopping list is', shoplist

print 'The first item I will buy is', shoplist[0]
olditem = shoplist[0]
del shoplist[0]
print 'I bought the', olditem
print 'My shopping list is now', shoplist

del len() append() sort() [int]
----------元组------
单个元组特殊 (2,)
---------字典---
ab = {       'Swaroop'   : 'swaroopch@byteofpython.info',
             'Larry'     : 'larry@wall.org',
             'Matsumoto' : 'matz@ruby-lang.org',
             'Spammer'   : 'spammer@hotmail.com'
     }
--------------索引------
shoplist = ['apple', 'mango', 'carrot', 'banana']
name = 'swaroop'
name[1:3]
name[2:]
name[1:-1]
name[:]
mylist = shoplist # mylist is just another name pointing to the same object!
mylist = shoplist[:] # make a copy by doing a full slice



--------------str-------
#!/usr/bin/python
# Filename: str_methods.py

name = 'Swaroop' # This is a string object

if name.startswith('Swa'):
    print 'Yes, the string starts with "Swa"'

if 'a' in name:
    print 'Yes, it contains the string "a"'

if name.find('war') != -1:
    print 'Yes, it contains the string "war"'

delimiter = '_*_'
mylist = ['Brazil', 'Russia', 'India', 'China']
分享到:
评论

相关推荐

    python数据结构与算法

    python数据结构与算法python数据结构与算法python数据结构与算法python数据结构与算法python数据结构与算法python数据结构与算法python数据结构与算法python数据结构与算法python数据结构与算法python数据结构与算法...

    Python数据结构与算法分析(第2版)1

    【Python数据结构与算法分析(第2版)】是一本专为Python程序员设计的书籍,旨在帮助读者深入了解数据结构和算法在Python环境中的应用。作者布拉德利·米勒和戴维·拉努姆以其丰富的实战经验,清晰地阐述了如何高效...

    Python数据结构课件.rar

    Python数据结构是编程基础的重要组成部分,它涉及到如何有效地组织和管理数据,以便高效地执行各种操作。本课件集合了关于Python数据结构的详细讲解,是期末考试复习的理想资源,同时也适合希望深入理解数据存储和...

    python数据结构与算法-已转档.pdf

    标题中的“Python数据结构与算法”指向了文档内容的核心主题,即通过Python语言来探索和实现数据结构与算法的相关知识。这部分内容主要涵盖Python编程语言中数据结构的实现方式、算法的设计技巧以及递归等编程概念的...

    Python数据结构与算法分析.docx

    Python 数据结构与算法分析 Python 数据结构与算法分析是计算机科学中的一门重要课程,涵盖了数据结构和算法两个方面的内容。在 Python 中,数据结构是指对数据的组织、存储和管理方式,而算法则是指解决问题或完成...

    Python 数据结构与算法 .chmPython 数据结构与算法 .chm

    Python 数据结构与算法 .chmPython 数据结构与算法 .chmPython 数据结构与算法 .chm

    Python数据结构与算法.chm

    《Python数据结构与算法》是一本深入探讨Python编程中数据结构和算法的专著,共有22个章节,旨在帮助读者理解并掌握Python语言在处理数据和优化计算过程中的核心概念。这本书以其清晰的讲解和易懂的例子,使得即便是...

    python数据结构思维导图

    本人在自学python数据结构的时候画的思维导图,超高清版本(第七章数据结构.bmp)

    Python数据结构与算法(英文)

    Python数据结构与算法(英文) Data Structures and Algorithms with Python

    python版数据结构学习

    ##### 2.5 Python数据结构的性能 讨论了Python内置数据结构(如列表和字典)的性能特点,并分析了它们在不同情况下的表现。 ##### 2.6 列表 深入研究Python列表的工作原理,包括其内部实现机制以及常见操作的复杂度...

    python 数据结构

    在Python编程语言中,数据结构是组织和存储数据的关键元素,它对于编写高效且易于管理的代码至关重要。这里我们将深入探讨标题"python 数据结构"所涵盖的几个核心数据结构:单链表、双向链表、栈和队列。这些概念在...

    Python的数据结构.pdf

    Python 数据结构是编程中至关重要的概念,它们提供了一种组织和管理数据的方式,使得代码更加高效和易读。本文主要探讨了Python中的四个内置数据结构:集合(Set)、序列(Sequence)、映射(Mapping),以及它们的...

    数据结构python数据结构练习题目与源代码

    3. python数据结构 4. python三大结构 5. 函数 第二部分--线性数据结构 1. 线性表 第三部分--非线性数据结构 1. 树和二叉树 2. 图 第四部分--数据结构操作 1. 查找 2. 排序 例如: 第七章 哈夫曼编码 # 树节点类...

    python数据结构.zip

    通过学习这个Python数据结构的详细教程,读者将能够理解这些核心概念,并能够灵活运用到实际编程中,解决复杂问题,提升代码的效率和可维护性。同时,实践中的代码示例将有助于加深理解,使理论知识转化为实用技能。

    python数据结构与算法视频教程.txt

    python数据结构与算法视频教程,包括网盘地址和密码,欢迎下载

    python数据结构与算法分析,希尔排序法实现,希尔排序.py

    python数据结构与算法分析,希尔排序法实现,希尔排序.py

Global site tag (gtag.js) - Google Analytics