zoukankan      html  css  js  c++  java
  • Python基础教程笔记——第3章:使用字符串

          字符串是不可修改的,标准序列操作(索引,分片,判断成员资格,求长度,取最大值

    最小值)对字符串都是有效的。

          格式化字符串,类似于C语言的输出是的感觉。

    >>> format="hello %s   %s are you ok?"

    >>> value=("yanliang","24")

    >>> print(format % value)

    hello yanliang   24 are you ok?

          find函数  a.find(s) >>> a.find('s',2) 设定了搜索的起始点  >>> a.find('s',1,2) 设置了起始点和结束点

          join函数  >>> sep='+' >>> seq=['1','2','3','4','5'] >>> sep.join(seq) 将sep分别的插入到seq中间

                        ‘1+2+3+4+5’                  

          lower函数 >>> a="HHGHGJ" >>> a.lower()  'hhghgj' 返回字符串的小写字母版

          replace函数  >>> a="HHGHGJ"  >>> a.replace('H','h')  'hhGhGJ' 将字符串中的H都用h代替

          split函数  join的逆方法,将字符串分割成片

                        >>> a='1+2+3+4+5'    >>> a.split('+')  ['1', '2', '3', '4', '5']

          strip函数  删除字符串两侧(不包括内部)空的字符串

                        >>> a='asi  '  >>> a.strip()  'asi'

          translate函数 

          

      

          

  • 相关阅读:
    ASP.NET 2.0 中的主版頁面 Master Pages
    初探ERP的数据库框架
    node.js 入门,
    mysql 测试
    zendframework 内置view
    session.save_Handler
    读mysql技术内幕 InnoDB 第三章
    php 的命名空间 看鸟哥后的随笔
    mysql innodb技术内幕 ~读 1,2,3 复习
    php 无乱码截取中文
  • 原文地址:https://www.cnblogs.com/yanliang12138/p/4695154.html
Copyright © 2011-2022 走看看