zoukankan      html  css  js  c++  java
  • Day2:The commonly used sentence of string and number

    # ************One:Number***********

    a="123"

    print(type(a),a)

    b=int(a)

    print(type(b),b)

    # Transfer the string to number

    # num='a'

    #v=int(num,base=16)

    #print(v)

    # Transfer the string to number

    #age=10

    #v=age.bit_length()

    #print(v)

    # Count the binary bits 

      

    # ************Two:String***********

    #test='alex'

    #v=test.capitalize()  #thefirstwordbecapital

    test='aleX'

    v=test.swapcase()

    # Swith between capital and lower-case

    # v=test.casefold() 

    # test.casefold()..better

    #v=test.islower() # judge

    #v=test.lower()   # switch

    #v=test.isupper() # judge

    #v=test.upper()   # switch

    # make the capital be a lower-case and converse

      

    # v=test.center(20,'*')

    # set length and put the content in the center

    # v= test.ljust(20,'~')

    # v= test.rjust(20,'~')

    print(v)

    #20 means the length

    # '*'  filled the blank: one character and have or not...

    # test='aleXeddecv'

    # v=test.count('e')

    # v=test.count('ex')

    # v=test.count('e',4)

    # v=test.count('e',4,6)

    # Count the subsequence in the string and set the start place to the end place)

    #encode

    #decode

    # test='aleXeddecv'

    # v=test.endswith('v',4,5)

    # v=test.startwith('v',4,5)

    # print(v)

    # test='zxver'

    # v=test.find('xv',1,4)

    # print(v)

    # Find the character from the start to the end 

    # Position ><=

    # test='I am {name},age {a}'

    # print(test)

    # v=test.format(name='zxver',a=26)

    #v=test.format_map({"name":'zxver',"a":26})

    # Ignore: v=test.index()

    # print(v)

    # Formatting :use a value to replace the placeholder of a string

    test='一'

    # v=test.isalnum()

    v1=test.isdecimal()

    # just for decimal is true

    v2=test.isdigit()

    # Can be true while symbolic number

    v3=test.isnumeric()

    # Even Chinese number is true

    #v=test.isalpha()

    print(v1,v2,v3)

    # Judges if the string just including number or word

    # test='username email password chenzaizhi 875804005@qq.com vgvhh888986 liukeyu 586975258@qq.com ghhhv688569'

    # v= test.expandtabs(25)

    # print(v)

    # Terminate the sentence with 25bytes and create a table

    # a='_zxef '

    # v= a.isidentifier()

    # print(v)

    # Judge is it qualified for identifier

    # v=a.isprintable()

    # if exist the characters that can't display : creat another line make table

    # print(v)

    # test='   '

    # v= test.isspace()

    # Judge if all the characters are blanks

    # print(v)

    # test='I Love liukeyu'

    # v1=test.istitle()

    # Judge if title

    # print(v1)

    # v2=test.title()

    # Switch to the format of title

    # print(v2)

    # v3=v2.istitle()

    # print(v3)

    # ******* important

    # test='1235468'

    # t=' '

    # v=t.join(test)

    # v='_'.join(test)

    # print(v)

    # Appoint a separator to link every character

    # test=' zverxd'

    # v=test.strip()

    # v=test.lstrip()

    # v= test.rstrip('vrd')

    #v=test.islower() # judge

    #v=test.lower()   # switch# Strip the blanks; ;appointed character(notice the sequence)

    # m='asdfg'

    # n=str.maketrans('asdfg','12345')

    # Make the rules

    # v=m.translate(n)

    # Replace

    # print(v)

    # test='xbhdhdbsj'

    # v=test.partition('h')

    # v=test.rpartition('h')

    # v=test.split('h')

    # v=test.rsplit('h')

    # print(v)

    # use partition or split depends if you want the separator

    # test='xbhdhdbsj jjjhhjkk '

    # v=test.splitlines(True)

    # devide the sentence :True of False to remain the or not

    # print(v)

      

    # Three:

        # **********7 basic magic**********

    # split strip join find upper lower replace

    # test='sbxhdhwjbxbx'

    # v=test.replace('bx','123',2)

    # print(v)

    # Four:

        # **********5 gray magic**********

    # test='sdxff'

    # v=test[0]

    # index:get the certain character of the string

    # v=test[0:4]

    # slice ' >= <'

    # print(v)

    # v=len(test) 

    # how many characters consists the string

    # print(v)

    # test='I love liukeyu'

    # index = 0

    # while index < len(test):

        # v = test[index]

        # print(v)

        # index += 1

    # print('#########')

    # for circulation********

    # for ai in test:

        # print(ai)

    # test=input('>>>>>>>')

    # for ai in test:

        # print(ai)

    # *****demand: print the index of the appointed character

    test = input('>>>>>')

    for ai in range(0,len(test)):

        print(ai,test[ai])

        

    # v=range(0,100,5)

    # creat continuous number or discontinuous number by setting steps

    # for ai in v:

        # print(ai)

    # Five:

        # *********deep gray magic********

    # *****Once the string is created it can't be changed ,if need be changed it will creat a new string

  • 相关阅读:
    微信小程序如何调用API实现数据请求-wx.request()
    微信小程序如何调用API实现数据请求-wx.request()
    详解Android数据存储技术
    详解Android数据存储技术
    详解Android数据存储技术
    带你走进CSS定位详解
    带你走进CSS定位详解
    bootstrap教程,SQL
    带你走进CSS定位详解
    jQuery基础与JavaScript与CSS交互-第五章
  • 原文地址:https://www.cnblogs.com/zxver/p/11936458.html
Copyright © 2011-2022 走看看