python第六天笔记

今日目标:
    排序(排序算法)
    字符串对象
    切片操作(有序序列)


排序:
1、为什么要排序
    为了快速查找

2、常见查找和排序算法
    排序:冒泡、选择、插入、希尔、快速、归并、堆排序、基数排序、计数排序……
    查找:二分查找

冒泡排序:
    原理:
        5 8 1 -3 11 100 -55 99
        # 冒泡算法
        1、 5 1 -3 8 11 -55 99 100    
        2、 1 -3 5 8 -55 11 99 100
        3、 -3 1 5 -55 8 11 99 100
        4、 -3 1 -55 5 8 11 99 100
        5、 -3 -55 1 5 8 11 99 100
        6、 -55 -3 1 5 8 11 99 100


选择排序:
    5 8 1 -3 11 100 -55 99
    1、-55 8 1 -3 11 100 5 99
    2、-55 -3 1 8 11 100 5 99
    3、-55 -3 1 5 11 100 8 99
    4、-55 -3 1 5 8 100 11 99
    5、-55 -3 1 5 8 11 100 99
    6、-55 -3 1 5 8 11 99 100 

插入排序:
    5 8 1 -3 11 100 -55 99
    1、 5 8                1 -3 11 100 -55 99
    2、 1 5 8            -3 11 100 -55 99
    3、 -3 1 5 8            11 100 -55 99
    4、 -3 1 5 8 11            100 -55 99
    5、 -3 1 5 8 11    100        -55 99
    6、 -55 -3 1 5 8 11 100        99
    7、 -55 -3 1 5 8 11 99 100        


二分查找(折半查找)
    要求自学

字符串对象:
    字符串在python中是基本数据类型
        单引号
        双引号
        三引号
    在python,字符串不仅仅是基本数据类型,也是一种对象
        ['capitalize', 'casefold', 'center', 'count', 'encode', 'endswith', 
        'expandtabs', 'find', 'format', 'format_map', 'index', 'isalnum', 
        'isalpha', 'isascii', 'isdecimal', 'isdigit', 'isidentifier',
        'islower', 'isnumeric', 'isprintable', 'isspace', 'istitle', 
        'isupper', 'join', 'ljust', 'lower', 'lstrip', 'maketrans', 
        'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition',
        'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip',
        'swapcase', 'title', 'translate', 'upper', 'zfill']
    
    |-- capitalize()        # 将字符串的首字母转为大写
    |-- center()            # 居中对齐方式
    |-- ljust()            # 左对齐
    |-- rjust()            # 右对齐
    |-- endswith()            # 以xxx结束
    |-- startswith()        # 以xx开始
    |-- format()            # 格式化字符串
    |-- index()            #
    |-- rindex()            #
    |-- find()            #
    |-- rfind()            #
    |-- replace()            # 
    |-- count()            # 统计数量
    |-- upper()
    |-- lower()        
    |-- strip()            #
    |-- title()            
    |-- istitle()
    |-- isalnum()

    |-- encode()            # 将字符串编码为字节数据(重要)
    |-- decode()            # 字节对象的方法!!!将字节数据转换为字符串数据
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值