String type 1, strip, lstrip, rstrip 2, lower, upper 3, startswith, endswith 4, format three play 5, split, rsplit 6, join 7, replace8, isdigit # Analyzing

Name = # "11YAng11xin11" 
# strip
# Print (name.strip ( ". 1")) to remove the same on both sides of the character #
# print (name.lstrip ( "1" )) # l: indicates left, the strip removed is equal to plus l left character
# print (name.rstrip ( "1" )) # r: represents the right, the strip plus r is equal to the right to remove the character

# Lower, Upper
# name = "11YAng11xin11"
# Print (name.lower ()) # the variables all capital letters to lower case as a = a
# Print (name.upper ()) # variable lowercase full capitalized as a = a

# startsWith, endsWith
# name = "yangxin_SB"
# Print ( name.endswith ( "B")) # final judgment of a character variable is correct
# print (name.startswith ( "a" )) # character at the beginning of a variable to determine whether the correct

# three uses format of
# wanfa = "{} {} {}" . format ( "yx", "xh", "dnn") # condemnation format which corresponds to the first character is a first} {
#Print (wanfa)
# wanfa2 = "{ 1} {0} {1} ". format ("yx "," xh "," dnn ") # Request for primers XH = 0 = YX. 1
#Print (wanfa2)
# wanfa3 = "{name}, {age}, {sex}". format (sex = "nv", name = "yang", age = 19) # understand at a glance
#Print (wanfa3)

#split
# name = 'root: the X-: 0: 0 :: / root: / bin / bash'
#split away any value in the string then this value will disappear,
# that value corresponding to the place turns into a form of a list of
#Print (name.split ( ':'))
# name = "D: / C / the ADS / the ASD / F., PY"
#Print (name.split ( "/",. 3)) # results: [ 'D: ',' C ',' the ADS ',' the ASD / F., PY ']
# name = "A | S | D | F | G"
#Print (name.rsplit ( "|",. 1)) to the right # r = the left and right segmentation

#join
# Wu = ""
#Print (wu.join ([ "Yangxin", "Xihuan", "nvde", "jiuxing"])) # object must be iterative string

# Replace
# name = "Yang XIN: I NiHao A Hai, Yang, A, Yang"
#Print (name.replace ( "yang", "sb ", 2)) # you need to change the values in the first place,
what # changed in the second, numbers represent from left to right on the input you need to change a few as few:
#sb XIN: I NiHao A Hai, SB, A, Yang

#isdigit:
Age = INPUT # ( ">>:")
#Print (age.isdigit ()) # determines whether the input is a digital

Guess you like

Origin www.cnblogs.com/yangxinpython/p/11128428.html