Meta-group
Tuple: The feature is the content is not variable, the list of read-only, can be queried, cannot be modified
A = 2,print(a)print= ('a','b ','C')print(b[1])
Operation Result:
(2,)<class'tuple'>b
Dictionary
Dictionary: Internal data is out of order when printed, the key value is hash, and there is uniqueness
#Create a dictionaryA = {'a':'python','b':'Ruby','C':'Java'}#Create a dictionary directlyPrint(a)#built-in Dictionary method creation: DictA = Dict (('a','b'),))Print(a) a= Dict ([['a','b'],])Print(a)#Modify DictionaryA = {'a':'b'}set1= A.setdefault ("C","Java")Print(a)Print(Set1)#Query OperationsA = {'a':'python','b':'Ruby','C':'Java'}Print(A.keys ())Print(A.values ())Print(A.items ())Print(a['a'])#Update MethodA = {'a':'python','b':'Ruby','C':'Java'}b= {'D':'Shell'}a.update (b)Print(a) a.update ({'a':'JavaScript'})Print(a)#Delete MethodA = {'a':'python','b':'Ruby','C':'Java'}a.clear ()Print(a)#Empty Dictionarya= {'a':'python','b':'Ruby','C':'Java'}dela['a']Print(a)Print("********************") A= {'a':'python','b':'Ruby','C':'Java'}b= A.pop ('b')Print(a)Print(b)Print("********************") A= {'a':'python','b':'Ruby','C':'Java'}b=A.popitem ()Print(a)Print(b) a= {'a':'python','b':'Ruby','C':'Java'}delA#the entire dictionary is deletedPrint('Other Dictionary methods') A= {' First':'python'}b= Dict.fromkeys (['a','b'],['Test'])Print(a)Print(b)Print('the traversal of a dictionary') A= {'a':'python','b':'Ruby','C':'Java'} forI,jinchA.items ():Print(I,J) forIinchA:#efficiency is higher than above Print(I,a[i])
String
List only a few simple applications
Print('Join String Merge method') A= ['python','Ruby','Java']b="'. Join (a)Print(b) C='*'. Join (a)Print(c)Print('String Common methods') A='python py'Print(A.count ('P'))Print(A.capitalize ())Print("Format formatted output") A="my favorite book {name} and {name2}"Print(A.format_map ({'name':'python','name2':'Java'}))Print(A.format (name ='Shell', name2 ='Bash'))Print(A.isdigit ())
Ps:
The previous data type is only the foundation, mastered the commonly used several built-in functions, the basic grammar can, in the learning function, the object some high-level topic, can continue to consolidate, so continue refueling bar
At work today when looking at Python, is the development of C + + despised, said too simple, alas, continue to refuel it
Re-learning Python-day 04-python Foundation---tuple + dictionary + string