I. Basic data types
Integer: int
String: str (note: \ t equals a TAB key)
Boolean value: BOOL
Listing: List
list with []
Ganso: Tuple
For Ganso ()
Dictionary: Dict
Note: All data types exist in the class column that you want to correspond to.
Two. List all data types:
Basic operation:
- Index
- Slice
- Additional
- Delete
- Length
- Slice
- Cycle
- Contains
List
classList (object):"""list (), New empty list List (iterable), new list initialized from iterable ' s items""" defAppend (self, p_object):#real signature unknown; restored from __doc__ """L.append (object), None--Append object to end"""(L.append (object)->--no object attached to the end)Pass defClear (self):#real signature unknown; restored from __doc__ """l.clear (), None--Remove all items from L"""(L.clear ()->No, put all items from L)Pass defCopy (self):#real signature unknown; restored from __doc__ """l.copy () List--a shallow copy of L"""(L.copy ()-> List-light copy of L)return [] defCount (self, value):#real signature unknown; restored from __doc__ """L.count (value), integer--return number of occurrences of value"""(L.count (value)->Integer, the number of occurrences of the return value)return0defExtend (self, iterable):#real signature unknown; restored from __doc__ """L.extend (iterable), None--extend list by appending elements from the iterable"""(L.extend (iterable)->no--add meta from iterable extension listPass defIndex (self, value, Start=none, Stop=none):#real signature unknown; restored from __doc__ """L.index (value, [Start, [stop]]), integer-return first index of value. Raises valueerror if the value is not present. (l index (value, [Start, [don't]])-> Integer, returns the first index value. Raised the value of ValueError if not present. ) """ return0defInsert (self, Index, p_object):#real signature unknown; restored from __doc__ """L.insert (Index, object)--Insert object before index"""(L Insert (Index (object)--pre-Insert Object index)Pass defPop (self, index=none):#real signature unknown; restored from __doc__ """l.pop ([index]), item-Remove and return item at index (default last). Raises indexerror If list is an empty or index is out of range. (L.pop (index))-> item-Delete and return the item index (default). The Indexerror is presented if the list is empty or the range of the index. ) """ Pass defRemove (self, value):#real signature unknown; restored from __doc__ """L.remove (value), None--Remove first occurrence of value. Raises valueerror if the value is not present. """(L.remove (value)->No, delete the first occurrence of the value. Raised the value of ValueError if not present. ) Pass defReverse (self):#real signature unknown; restored from __doc__ """L.reverse ()--Reverse *in place*""" Pass defSort (self, key=none, reverse=false):#real signature unknown; restored from __doc__ """L.sort (Key=none, Reverse=false), None--stable sort *in place*""" Pass def __add__(Self, *args, **kwargs):#Real Signature Unknown """Return Self+value.""" Pass def __contains__(Self, *args, **kwargs):#Real Signature Unknown """Return key in self.""" Pass def __delitem__(Self, *args, **kwargs):#Real Signature Unknown """Delete Self[key].""" Pass def __eq__(Self, *args, **kwargs):#Real Signature Unknown """Return Self==value.""" Pass def __getattribute__(Self, *args, **kwargs):#Real Signature Unknown """Return getattr (self, name).""" Pass def __getitem__(Self, y):#real signature unknown; restored from __doc__ """x.__getitem__ (y) <==> X[y]""" Pass def __ge__(Self, *args, **kwargs):#Real Signature Unknown """Return Self>=value.""" Pass def __gt__(Self, *args, **kwargs):#Real Signature Unknown """Return Self>value.""" Pass def __iadd__(Self, *args, **kwargs):#Real Signature Unknown """Implement Self+=value.""" Pass def __imul__(Self, *args, **kwargs):#Real Signature Unknown """Implement Self*=value.""" Pass def __init__(Self, seq= ()):#known special case of list.__init__ """list (), New empty list List (iterable), new list initialized from iterable ' s items # (c Opied from class doc)""" Pass def __iter__(Self, *args, **kwargs):#Real Signature Unknown """Implement iter (self).""" Pass def __len__(Self, *args, **kwargs):#Real Signature Unknown """Return len (self).""" Pass def __le__(Self, *args, **kwargs):#Real Signature Unknown """Return Self<=value.""" Pass def __lt__(Self, *args, **kwargs):#Real Signature Unknown """Return Self<value.""" Pass def __mul__(Self, *args, **kwargs):#Real Signature Unknown """Return SELF*VALUE.N""" Pass@staticmethod#known case of __new__ def __new__(*args, **kwargs):#Real Signature Unknown """Create and return a new object. See Help (type) for accurate signature. """ Pass def __ne__(Self, *args, **kwargs):#Real Signature Unknown """Return Self!=value.""" Pass def __repr__(Self, *args, **kwargs):#Real Signature Unknown """Return repr (self).""" Pass def __reversed__(self):#real signature unknown; restored from __doc__ """l.__reversed__ ()--return a reverse iterator over the list""" Pass def __rmul__(Self, *args, **kwargs):#Real Signature Unknown """Return Self*value.""" Pass def __setitem__(Self, *args, **kwargs):#Real Signature Unknown """Set Self[key] to value.""" Pass def __sizeof__(self):#real signature unknown; restored from __doc__ """l.__sizeof__ ()--size of L in memory, in bytes""" Pass __hash__= None
Three. Examples of all list data types
#!/usr/bin/env python#-*-coding:utf-8-*-#append追加name_list = ["Zhangyanlin", "suoning", "Nick"]name_list.append (' Zhang ') print (name_list) #count制定字符出现几次name_list = ["Zhangyanlin", "suoning", "Nick"]name_list.append (' Zhang ') name_ List.append (' Zhang ') name_list.append (' Zhang ') print (Name_list.count (' Zhang ')) #extend可扩展, bulk to riga data name_list = [" Zhangyanlin "," suoning "," nick "]name = [" Aylin "," Zhang "," Yan "," Lin "]name_list.extend (name) print (name_list) # Index where the character is located name_list = ["Zhangyanlin", "suoning", "Nick"]print (Name_list.index (' Nick ')) #insert插入, inserting values into the index name_ List = ["Zhangyanlin", "suoning", "Nick"]name_list.insert (1, "Zhang") print (name_list) #pop在原列表中移除掉最后一个元素, and assign to another variable name_list = ["Zhangyanlin", "suoning", "nick"]name = Name_list.pop () print (name) #remove移除, only remove the first name_ found from the left List = ["Zhangyanlin", "suoning", "Nick"]name_list.remove (' Nick ') print (name_list) #reverse反转name_list = ["Zhangyanlin "," suoning "," Nick "]name_list.reverse () print (name_list) #del删除其中元素, remove name_list = [" Zhangyanlin "," suoning "from 1 to 3," Nick "]del NAMe_list[1:3]print (Name_list)
Four. Index
Name_list = ["Zhangyanlin", "suoning" "Aylin" "Nick"]print (Name_list[0])
Five. Slicing
Name_list = ["Zhangyanlin", "suoning" "Aylin" "Nick"]print (Name_list[0:2])
Six. Total length len
Name_list = ["Zhangyanlin", "suoning" "Aylin" "Nick"]print (Name_list[1:len (name_list)])
Seven. For loop
Name_list = ["Zhangyanlin", "suoning" "Aylin" "Nick"]for I in Name_list:print (i)
List of Python data types