. delimiter by specifying the string and returns a list of segmentation, default delimiter is all null characters
similar split () method, but is a string from the last start-split surface.
'' '
Print (' * '* 50)
S2 = dss.join ([' A ','. ',' C '])
Print (' >> S2 ', S2)
S3 =' S3 '
S3 = +' XX '
Print (' >> S3 ', S3)
' ''
the Join () method is used to specify the elements of a sequence is connected to generate a new character string.
'' '
Print (' * '* 50)
CSS = "abc1c2c3"
PI = css.find (' C ')
Print (' >> PI ', PI)
Print ( "*" 50 *)
S1, S2 =' ABC ',' ABC123efg '
Print (S1,': uppercase >> ', s1.upper ())
Print (S2,': lowercase >> ', s2.lower ())
Print (S2, ":
python3 removed CMP () function, but provides a wealth of six comparison operators
print("insert>>",ls1)
import operator # operator must first import module
operator.gt (1,2) # mean greater than (greater than)
operator.ge (1,2) # mean greater and equal (or greater)
operator.eq (1,2 ) # mean equal (equivalent)
operator.le (1,2) # mean less and equal (or less)
operator.lt (1,2) # mean less than (less than)
'' '
LS1 = [. 1, 2,3,4]
LS2 = [8,5,6]
TP = (11,22,33,44)
Print ( "CMP >>", operator.gt (LS1, LS2))
Print ( "len >>" , len (LS1))
Print ( ">> max", max (LS1))
Print ( "min >>", min (LS1))
Print ( ">> List", List (TP))
Print ( "*" 30 *)
LS1 = [1,2,3,4]
ls1.append ( 'A')
Print ( "the append >>", LS1)
LS1.
print ( "*" * 30)
print ( "pop >>", ls1.pop ()) # default last
ls1 = [1,2,3,4,5,6,1,2,3,4,6,5,4]
ls1.remove (2)
Print ( "remove >>", LS1) # remove only the first match
ls1.reverse ()
Print ( 'Reverse >>', LS1)
ls2.sort ()
Print ( '>> Sort', LS2)
Print ( '#' * 50, "Dictionary")
dict1 = { 'A': 97, 'B': 98}
dict2 = { 'A': 65, 'B': 66}
# Print ( "CMP> > ", cmp (dict1, dict2))
Print (" len >> ", len (dict1))
Print (" str >> ", str (dict1))
Print (" >> of the type ", of the type (dict1))
Print ( "#" * 50, "using the partial function")
DEF the Add (a, B):
return a + B
Print ( "the Add (. 4 + 2) =", the Add (. 4,2))
p3 = functools.partial(add,3)
p5 = functools.partial(add,5)
r2 = p3(4)
print("p3(4)=",r2)
r3 = p3(7)
print("p(7)=",r3)
r4 = p5(10)
print('p5(7)=',r4)
print('#'*50,"类的动态属性")
class MyClass(object):
def __init__(self):
self.__param = None
def getParam(self):
print("get param:%s " % self.__param)
return self.__param
def setParam(self,value):
print("set param:%s " % self.__param)
self.__param = value
def delParam(self):
print("del param:%s " % self.__param)
del self.__param
param= property(getParam,setParam,delParam)
class MyClass1(object):
def __init__(self):
self.__param = None
@property
def param(self):
print("get param: %s " % self.__param)
return self.__param
@param.setter
def param(self,value):
print("set param: %s " % self.__param)
self.__param = value
@param.deleter
def param(self):
print("del param: %s " %self.__param)
del self.__param
if __name__ == '__main__':
cls = MyClass()
cls.param = 10
print("current param:%s " % cls.param)
del cls.param
print("*"*30)
cls1 = MyClass1()
cls1.param = 10
print("current param: %s " % cls1.param)
del cls1.param