zoukankan      html  css  js  c++  java
  • 字符串


    >>> a='abcdefg' >>> a 'abcdefg' >>> a[::-2] 'geca' >>> a[::] 'abcdefg' >>> a[::-1] 'gfedcba' >>> a = 'abcdef' >>> a 'abcdef' >>> a[::-1] 'fedcba' >>> a 'abcdef' >>> a[4:3] '' >>> a[4:3:-1] 'e'

    >>> mystr = 'hello world wanglinjie linjie w_linjie' >>> mystr.find("linjie") 16 >>> mystr.find("linjie",0,10) -1 >>> mystr.count("linjie") 3
    >>> mystr.replace("linjie","LinJie") 'hello world wangLinJie LinJie w_LinJie'

    >>> mystr.replace("linjie","LinJie",1) 'hello world wangLinJie linjie w_linjie'
    >>> mystr.split(" ") ['hello', 'world', 'wanglinjie', 'linjie', 'w_linjie']
    >>> mystr.split(" ",2) ['hello', 'world', 'wanglinjie linjie w_linjie']
    >>> mystr.split(" ",3) ['hello', 'world', 'wanglinjie', 'linjie w_linjie']
    >>> mystr.capitalize() 'Hello world wanglinjie linjie w_linjie'
    >>> mystr.title() 'Hello World Wanglinjie Linjie W_Linjie'
    >>> mystr.startswith("hello") True >>> mystr.startswith("Hello") False >>> mystr.endswith("jie") True >>> mystr.endswith("Jie") False >>>
    >>> Mystr=ystr = 'Hello World Wanglinjie Linjie W_Linjie'
    >>> Mystr.lower()
    'hello world wanglinjie linjie w_linjie'
    >>> 
    >>> Mystr=ystr = 'Hello World Wanglinjie Linjie W_Linjie'
    >>> Mystr.lower() 'hello world wanglinjie linjie w_linjie'
    >>> Mystr.upper() 'HELLO WORLD WANGLINJIE LINJIE W_LINJIE'
    >>> Mystr.ljust(10) 'Hello World Wanglinjie Linjie W_Linjie'
    >>> my = 'wang' >>> my.ljust(10) 'wang '>>> mystr.rjust(10) 'hello world wanglinjie linjie w_linjie' >>> my.rjust(10) ' wang' >>> mystr.center(10) 'hello world wanglinjie linjie w_linjie' >>> my.center(10) ' wang ' >>> my.lstrip() 'wang' >>> a = ' linjie ' >>> a.lstrip() 'linjie ' >>> a.rstrip() ' linjie' >>> a.strip() 'linjie' >>>
    >>> mystr
    'hello world wanglinjie linjie w_linjie'
    >>> mystr.rfind("linjie")
    32
    >>> mystr.partition("linjie")
    ('hello world wang', 'linjie', ' linjie w_linjie')
    >>> mystr.rpartition("linjie")
    ('hello world wanglinjie linjie w_', 'linjie', '')
    >>> mystr = 'abc'
    >>> mystr.isalpha()
    True
    >>> mystr.isdigit()
    False
    >>> mystr1 = '123'
    >>> mystr1.isalpha()
    False
    >>> mystr1.isdigit()
    True
    >>> mystr2 = 'abc123'
    >>> mystr2.isalnum()
    True
    >>> mystr1.isalnum()
    True
    >>> mystr.isalnum()
    True
    >>> mystr3 = ' '
    >>> mystr3.isalnum()
    False
    >>> mystr3.isspace()
    True
    >>> mystr = ' '
    >>> li = ["my","name","is","linjie"]>>> mystr.join(li)
    'my name is linjie'
    >>> a = '_'
    >>> a.join(li)
    'my_name_is_linjie'
    >>> 
  • 相关阅读:
    【转载】分布式之redis复习精讲
    Oracle学习笔记——常用函数总结
    数据库 字段动态添加
    c# form的设定
    C# 单元测试,测试资源管理器里面没有需要的单元测试
    Nvidia--cuda--document
    C# 文件的读取与另存为(WPF)
    java反射概述
    java设计模式:工厂模式
    oracle表被锁定的解决办法
  • 原文地址:https://www.cnblogs.com/wanglinjie/p/9108433.html
Copyright © 2011-2022 走看看