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

 

Surely # = '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 = 'a'

# 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 \ temail \ tpassword \ nchenzaizhi \ [email protected] \ tvgvhh888986 \ nliukeyu \ [email protected] \ tghhhv688569'

# v= test.expandtabs(25)

# Print (v)

# Terminate the sentence with 25bytes and create a table

 

A = # '_ zxef \ t'

# V = a.isidentifier ()

# Print (v)

# Judge is it qualified for identifier

 

# V = a.isprintable ()

# if exist the characters that can't display :\n creat another line \t 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;\t \n;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\njjjhhjkk\n'

# v=test.splitlines(True)

# devide the sentence :True of False to remain the \n 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 [of])

    

# 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

 

 

 

 

Guess you like

Origin www.cnblogs.com/zxver/p/11936458.html