Python string magic seven


################ six basic magic ###################
#join '_' the Join (XXXXX)
#split
#find
#strip
#upper
#lower



################ gray magic ######################## ###
the Test = "you kind of come at me," # index, subscript, get one character string
index = 0
the while index <len (the Test):
v = the Test [index]
Print (v)
index + . 1 =



#for cycle Note: for in a string variable
# variable name
for ZJW in Test:
Print (ZJW)


V = Test [. 3]
Print (V)

# slice
v1 = test [0: 1] # 0 = <<1
Print (V1)

V1 = [0: -1] Test # 0 = <<-1
Print (V1)

# to python3: len obtain current string of several characters len = length
len = V3 (Test)
Print (V3)

#
len ( "fasfsd")
V = '_'. the Join ( "dasdasdadad") # string in each join a _
Print (V)

#
Li = [. 11, 22,33,44,55, "asdf", 444,999] # len list in accordance with the number of comma
len ( "dasdasdad")
V = len (Li)
Print (V)


S = "dakdd; sdsd" # k as the separator
V4 = s.split ( "K")
Print (V4)

Guess you like

Origin www.cnblogs.com/159357zzx/p/11503114.html