Python内置容器之字符串

3.字符串str

    在Python3中字符串是unicode序列,类似于存储字符的列表;元素是可哈希的常量,字符串本身是一种不可变的,可哈希的线性数据结构

    【1】字符串定义

        用引号'A'|"B"|'''C''',或者str函数

    【2】连接 join

 

    【3】分割 splite rsplite splitlines partition rpatition

        split 从左到右分割开            str --> list

        rsplit 从右往左分割        str --> list

        splitlines 以换行符为分割符,分割全部        str --> list

        partition 保留分隔符,从左往右分割全部        str --> tuple

        rpartition 保留分隔符,从右往左分割        str --> tuple

    【4】修改 capitalize title upper lower swapcase | center ljust rjust zfill | strip lstrip rstrip

        自然语言的修改 ,大小写capitalize title upper lower swapcase

        

        程序语言的修改

          填充 center ljust rjust zfill

        去除 strip lstrip rstip

    【5】判断 endswith

    【6】查找替换 count find rfind index rindex replace

        count 字符计数

        find 值查找,从左往右第一个

        rfind 值查找,从右往左第一个

        index 值索引

        replace

    【7】格式化 print style | format

        print style

        format方法

        【8】bytes

转载于:https://my.oschina.net/charlock/blog/744924

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值