zoukankan      html  css  js  c++  java
  • 015_string

    #!/usr/bin/env python
    # Author:liujun

    name = "my name is aliex"

    print(name.capitalize())
    # Capitalize the first letter

    print(name.count('a'))
    # Count the number of specified character

    print(name.center(50, "-"))
    # The result is ----------------------aliex-----------------------

    print(name.endswith("x"))
    # Decide whether the string end with specified character and return boolean

    print(name.find("name"))
    print(name.find("y"))
    # Get the index of the first character of the given string

    name = "my name is {name} and i am {year} old"
    print(name.format(name="alex",year=33))

    print(name.isalnum())
    print(name.isalpha())
    print(name.isdigit())
    # Decide if it is a digit
    print(name.isdecimal())
    # Decide if it is decimal
    print(name.isidentifier())
    # Decide if it is a valid identifier.

    print(name.islower())
    print(name.isupper())
    print(name.isnumeric())
    print(name.istitle())
    print(name.isprintable())

    print('+'.join( ['1','2','3']) )

    print( name.ljust(50,'*') )
    print( name.rjust(50,'-') )

    print( 'Alex'.lower() )
    print( 'Alex'.upper() )


    print( ' Alex'.lstrip() )
    print( 'Alex '.rstrip() )
    print( ' Alex '.strip() )


    p = str.maketrans("abcdefli",'123$@456')
    print("alex li".translate(p) )

    print('alex li'.replace('l','L',1))

    print('alex lil'.rfind('l'))

    print('1+2+3+4'.split(' '))
    print('1+2 +3+4'.splitlines())

    print('Alex Li'.swapcase())
    print('lex li'.title())
    print('lex li'.zfill(50))






  • 相关阅读:
    window.fonts
    smpt authentification 配置
    如何从思维上应对
    中文字体 英文字体
    Path Breadcrumbs
    drupal commerce app
    做视频或者什么模块开发之类的
    分页符 箭头 难看
    theme wrapper 例子
    background position 稍微深入
  • 原文地址:https://www.cnblogs.com/liujun5319/p/9588521.html
Copyright © 2011-2022 走看看