Basic data types in Day02python-lists and Ganso and dictionaries

Source: Internet
Author: User
Tags iterable shallow copy

List

To create a list:

name_list=[' Leo ', ' Day ', ' up '

Or

Name_list=list ([' Leo ', ' Day ', ' up '])

Basic operation:

Index:

Slice:

Additional:

Delete:

Length:

Slice:

Cycle:

Contains:

Class List (object): "" "List (), New empty list List (iterable), new list initialized from Iterable ' ite MS "" "Def append (self, p_object): # Real signature unknown; Restored from __doc__ "" "L.append (object)--Append object to End" "" Pass Def count (self, value): # REA L signature Unknown;     Restored from __doc__ "" "L.count (value)--return number of occurrences of value" "" Return 0 def extend (self, iterable): # Real signature unknown;     Restored from __doc__ "" "L.extend (iterable) – Extend list by appending elements from the iterable" "" Pass def index (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. "" "Return 0 def insert (self, Index, p_object): # Real signature unknown;     Restored from __doc__   "" "L.insert (Index, object)--Insert object before index" "Pass def pop (self, index=none): # real Signatur e 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. "" "Pass def Remove (self, value): # Real signature unknown;        Restored from __doc__ "" "" L.remove (value)--Remove first occurrence of value.        Raises valueerror if the value is not present. "" "Pass Def Reverse (self): # real signature unknown; Restored from __doc__ "" "L.reverse () – Reverse *in place*" "" Pass def sort (self, cmp=none, Key=none, R Everse=false): # Real signature unknown;        Restored from __doc__ "" "L.sort (Cmp=none, Key=none, Reverse=false)--stable sort *in place*; CMP (x, y)-1, 0, 1 "" "Pass Def __add__ (self, y): # Real signature unknown; RestoredFrom __doc__ "" "x.__add__ (y) <==> x+y" "" Pass Def __contains__ (self, y): # Real Signature Unknown ; Restored from __doc__ "" "X.__contains__ (y) <==> y in X" "" Pass Def __delitem__ (self, y): # real S Ignature unknown; Restored from __doc__ "" "x.__delitem__ (y) <==> del x[y]" "" Pass Def __delslice__ (self, I, J): # r EAL signature Unknown; Restored from __doc__ "" "X.__delslice__ (i, J) <==> del X[i:j] Us        E of negative indices is not supported. "" "Pass Def __eq__ (self, y): # Real signature unknown; Restored from __doc__ "" "x.__eq__ (y) <==> x==y" "" Pass Def __getattribute__ (self, name): # real S Ignature unknown;  Restored from __doc__ "" "x.__getattribute__ (' name ') <==> x.name" "" Pass Def __getitem__ (self, y): # Real Signature Unknown; Restored from __doc__ "" "x.__getitem__ (y) <==> x[y]""Pass Def __getslice__ (self, I, j): # Real signature unknown;  Restored from __doc__ "" "X.__getslice__ (i, J) <==> X[i:j] use of        Negative indices is not supported. "" "Pass Def __ge__ (self, y): # Real signature unknown; Restored from __doc__ "" "x.__ge__ (y) <==> x>=y" "" Pass Def __gt__ (self, y): # Real Signature U Nknown; Restored from __doc__ "" "X.__gt__ (y) <==> x>y" "" Pass Def __iadd__ (self, y): # Real Signature Unknown Restored from __doc__ "" "x.__iadd__ (y) <==> x+=y" "" Pass Def __imul__ (self, y): # Real Signature Unknown Restored from __doc__ "" "X.__imul__ (y) <==> x*=y" "" Pass Def __init__ (self, seq= ()): # known Spec ial Case of list.__init__ "" "List (), New empty list List (iterable), new list initialized F      Rom iterable ' s items # (copied from class Doc)  "" "Pass Def __iter__ (self): # real signature unknown; Restored from __doc__ "" "x.__iter__ () <==> iter (x)" "" Pass Def __len__ (self): # real Signature UN known; Restored from __doc__ "" "x.__len__ () <==> len (x)" "" Pass Def __le__ (self, y): # Real Signature UN known; Restored from __doc__ "" "x.__le__ (y) <==> x<=y" "" Pass Def __lt__ (self, y): # Real Signature U Nknown; Restored from __doc__ "" "X.__lt__ (y) <==> x<y" "" Pass Def __mul__ (self, n): # Real Signature U Nknown; Restored from __doc__ "" "X.__mul__ (n) <==> x*n" "" Pass @staticmethod # known case of __new__ D EF __new__ (S, *more): # Real signature unknown; Restored from __doc__ "" "t.__new__ (S, ...) A new object with type S, a subtype of T "" "Pass Def __ne__ (self, y): # Real signature unknown; Restored from __doc__ "" "x.__ne__ (y) <==> x!=y" "" "Pass DEF __repr__ (self): # real signature unknown; Restored from __doc__ "" "x.__repr__ () <==> repr (x)" "" Pass Def __reversed__ (self): # real Signatu Re unknown; Restored from __doc__ "" "L.__reversed__ () – Return a reverse iterator over the list" "" Pass def __rmul __ (self, N): # real signature unknown; Restored from __doc__ "" "X.__rmul__ (n) <==> n*x" "" Pass Def __setitem__ (self, I, y): # Real Signa Ture unknown;  Restored from __doc__ "" "x.__setitem__ (i, y) <==> x[i]=y" "" Pass Def __setslice__ (self, I, J, y): # Real Signature Unknown; Restored from __doc__ "" "X.__setslice__ (i, J, y) <==> x[i:j]=y U        SE of negative indices is not supported. "" "Pass Def __sizeof__ (self): # real signature unknown; Restored from __doc__ "" "l.__sizeof__ ()--size of L in memory, in bytes" "" Pass __hash__ = None

5. Yuan zu

To create a meta-ancestor:

Ages= (12,23,32,33,44)

Or

Ages=tuple ((12,23,32,33,44))

Basic operation:

-Index

-Slicing

-Cycle

-Length

-Includes

Lass Tuple (object): "" "tuple (), empty tuple tuple (iterable), tuple initialized from iterable ' s items    If The argument is a tuple, the return value is the same object. "" "Def count (self, value): # Real signature unknown;     Restored from __doc__ "" "T.count (value)--return number of occurrences of value" "" Return 0 def index (self, value, Start=none, Stop=none): # Real signature unknown;        Restored from __doc__ "" "T.index (value, [Start, [Stop]), integer-return first index of value.        Raises valueerror if the value is not present. "" "Return 0 def __add__ (self, y): # Real signature unknown; Restored from __doc__ "" "x.__add__ (y) <==> x+y" "" Pass Def __contains__ (self, y): # real Signatur e unknown; Restored from __doc__ "" "X.__contains__ (y) <==> y in X" "" Pass Def __eq__ (self, y): # Real Signat Ure unknown; Restored from __doc__ """ X.__eq__ (y) <==> x==y "" "Pass Def __getattribute__ (self, name): # real signature unknown;  Restored from __doc__ "" "x.__getattribute__ (' name ') <==> x.name" "" Pass Def __getitem__ (self, y): # Real Signature Unknown; Restored from __doc__ "" "x.__getitem__ (y) <==> x[y]" "" Pass Def __getnewargs__ (self, *args, **kwa RGS): # Real Signature Unknown pass def __getslice__ (self, I, j): # Real signature unknown;  Restored from __doc__ "" "X.__getslice__ (i, J) <==> X[i:j] use of        Negative indices is not supported. "" "Pass Def __ge__ (self, y): # Real signature unknown; Restored from __doc__ "" "x.__ge__ (y) <==> x>=y" "" Pass Def __gt__ (self, y): # Real Signature U Nknown; Restored from __doc__ "" "X.__gt__ (y) <==> x>y" "" Pass Def __hash__ (self): # real Signature UNK Nown;       Restored from __doc__ "" "x.__hash__ () <==> hash (x)" "" Pass Def __init__ (self, seq= ()): # Known special case of tuple.__init__                "" "Tuple (), empty tuple tuple (iterable), tuple initialized from iterable ' s items        If The argument is a tuple, the return value is the same object. # (copied from class Doc) "" "Pass Def __iter__ (self): # real signature unknown; Restored from __doc__ "" "x.__iter__ () <==> iter (x)" "" Pass Def __len__ (self): # real Signature UN known; Restored from __doc__ "" "x.__len__ () <==> len (x)" "" Pass Def __le__ (self, y): # Real Signature UN known; Restored from __doc__ "" "x.__le__ (y) <==> x<=y" "" Pass Def __lt__ (self, y): # Real Signature U Nknown; Restored from __doc__ "" "X.__lt__ (y) <==> x<y" "" Pass Def __mul__ (self, n): # Real Signature U Nknown; Restored from __doc__ "" "X.__mul__ (n) <==> x*n"" "Pass @staticmethod # known case of __new__ def __new__ (S, *more): # Real signature unknown; Restored from __doc__ "" "t.__new__ (S, ...) A new object with type S, a subtype of T "" "Pass Def __ne__ (self, y): # Real signature unknown; Restored from __doc__ "" "x.__ne__ (y) <==> x!=y" "" Pass Def __repr__ (self): # real Signature Unkno Wn Restored from __doc__ "" "x.__repr__ () <==> repr (x)" "" Pass Def __rmul__ (self, n): # real Signatur e unknown; Restored from __doc__ "" "X.__rmul__ (n) <==> n*x" "" Pass Def __sizeof__ (self): # real Signature UN known; Restored from __doc__ "" "t.__sizeof__ ()--size of T in memory, in bytes" "" Pass

6. Dictionary (unordered)

To create a dictionary:

person={"name": "Mr.wu", ' Age ': 18}

Or

Person=dict ({' name ': ' Mr.wu ', ' Age ': 18})

Common operations:

-Index

-New

-delete

-Key, value, key-value pairs

-Cycle

-Length

Class Dict (object): "" "Dict (), New Empty Dictionary dict (mapping), new dictionary initialized from a m        Apping object ' s (key, value) pairs Dict (iterable), new dictionary initialized as if via:d = {}        For K, V in iterable:d[k] = v dict (**kwargs)-New dictionary initialized with the name=value pairs  In the keyword argument list. For Example:dict (one=1, two=2) "" "Def Clear (self): # real signature unknown;  Restored from __doc__ "" "Purge Contents" "" "" D.clear ()-None. Remove all items from D. "" "Pass def Copy (self): # real signature unknown; Restored from __doc__ "" "Shallow Copy" "" "" "D.copy () a shallow copy of D" "Pass @staticmethod # Known Case def Fromkeys (S, V=none): # Real signature unknown;        Restored from __doc__ "" "Dict.fromkeys (S[,v]), New dict with keys from S and values equal to V.        V defaults to None.        """Pass Def get (self, k, d=none): # Real signature unknown;  Restored from __doc__ "" "gets the value based on key, D is the default value" "" "" "D.get (K[,d]), D[k] if k in D, else D. D defaults to None. "" "Pass Def Has_key (self, k): # Real signature unknown; Restored from __doc__ "" "whether there is a key" "" "" "" D.has_key (k)-True if D has a key K, else False "" "ret Urn False def items (self): # real signature unknown;        Restored from __doc__ "" "List of all items in form" "" "" "D.items (), List of D ' s (key, value) pairs, as 2-tuples" "" return [] def iteritems (self): # real signature unknown;        Restored from __doc__ "" "Item Can Iterate" "" "" "D.iteritems (), an iterator over the (key, value) items of D" "" Pass Def Iterkeys (self): # real signature unknown;    Restored from __doc__ "" "Key Can Iterate" "" "" "" "D.iterkeys () an iterator over the keys of D" "" Pass def itervalues (self): # real signature unknown;    Restored from __doc__    "" "Value Can Iterate" "" "" "" "" "" D.itervalues (), an iterator over the values of D "" "Pass def Keys: # Real signature unknown; Restored from __doc__ "" "All Key List" "" "" D.keys () List of D ' s Keys "" return [] def pop (s Elf, K, D=none): # Real signature unknown;  Restored from __doc__ "" "gets and Removes" "" "" "" D.pop (K[,d]), remove specified key and return in the dictionary        corresponding value. If key is no found, D is returned if given, otherwise keyerror is raised "" "Pass Def Popitem (self): # R EAL signature Unknown; Restored from __doc__ "" "gets and Removes" "" "" "" D.popitem (), "" "" "In the dictionary (k, v), remove and return some (key, VA Lue) pair as a 2-tuple;        But raise Keyerror if D is empty. "" "Pass Def SetDefault (self, k, d=none): # Real signature unknown; Restored from __doc__ "" "If key does not exist, it is created, if present, returns the existing value and does not modify" "" "" "" D.setdefault (K[,d]), D.get (k,d), ALSo Set D[k]=d if K not in D ' "" Pass def update (self, E=none, **f): # Known special case of Dict.update "" "Update {' name ': ' Alex ', ' Age ': 18000} [(' Name ', ' SBSBSB '),]" "" "" D.update ([E,]*  *F), None.        Update D from Dict/iterable E and F. If e present and has A. Keys () method, Does:for k in e:d[k] = e[k] If e present and lacks. Keys () method, Doe S:for (k, v) in e:d[k] = V In either case, the is followed By:for k in f:d[k] = F[k] "" "Pas s def values (self): # real signature unknown; Restored from __doc__ "" "All Values" "" "" D.values () List of D ' s Values "" return [] def Viewi TEMs (self): # real signature unknown;  Restored from __doc__ "" "All items, just save content to the View object" "" "" D.viewitems ()-a Set-like object providing a view On D's Items "" "Pass Def Viewkeys (self): # real signature unknown; Restored from __doc__ "" "D.viewkeYS ()-a Set-like object providing a view on D's Keys "" "Pass Def Viewvalues (self): # real Signature Unknow N Restored from __doc__ "" "D.viewvalues (), an object providing a view on D ' s values" "" Pass def __CM P__ (self, y): # Real signature unknown; Restored from __doc__ "" "x.__cmp__ (y) <==> cmp (x, y)" "" Pass Def __contains__ (self, k): # Real SIG Nature unknown; Restored from __doc__ "" "" "d.__contains__ (k)-True if D has a key K, else false" "" return False Def __delitem__ (self, y): # Real signature unknown; Restored from __doc__ "" "x.__delitem__ (y) <==> del x[y]" "" Pass Def __eq__ (self, y): # Real Signa Ture unknown; Restored from __doc__ "" "x.__eq__ (y) <==> x==y" "" Pass Def __getattribute__ (self, name): # real S Ignature unknown;  Restored from __doc__ "" "x.__getattribute__ (' name ') <==> x.name" "" Pass Def __getitem__ (self, y): # Real Signature unknown;  Restored from __doc__ "" "x.__getitem__ (y) <==> x[y]" "" Pass Def __ge__ (self, y): # Real Signature Unknown Restored from __doc__ "" "x.__ge__ (y) <==> x>=y" "" Pass Def __gt__ (self, y): # Real Signature U Nknown; Restored from __doc__ "" "X.__gt__ (y) <==> x>y" "" Pass Def __init__ (self, Seq=none, **kwargs): # known special case of dict.__init__ "" "Dict (), New Empty Dictionary dict (mapping), new D Ictionary initialized from a mapping object ' s (key, value) pairs Dict (iterable), new dictionary INI  Tialized as if via:d = {} for K, V in iterable:d[k] = v dict (**kwargs)  New dictionary initialized with the name=value pairs in the keyword argument list. For Example:dict (one=1, two=2) # (copied from class Doc) "" "Pass Def __iter__ (self): # real SIG Nature UnknoWn Restored from __doc__ "" "x.__iter__ () <==> iter (x)" "" Pass Def __len__ (self): # real Signature UN known; Restored from __doc__ "" "x.__len__ () <==> len (x)" "" Pass Def __le__ (self, y): # Real Signature UN known; Restored from __doc__ "" "x.__le__ (y) <==> x<=y" "" Pass Def __lt__ (self, y): # Real Signature U Nknown;    Restored from __doc__ "" "X.__lt__ (y) <==> x<y" "" Pass @staticmethod # known case of __new__ def __new__ (S, *more): # Real signature unknown; Restored from __doc__ "" "t.__new__ (S, ...) A new object with type S, a subtype of T "" "Pass Def __ne__ (self, y): # Real signature unknown; Restored from __doc__ "" "x.__ne__ (y) <==> x!=y" "" Pass Def __repr__ (self): # real Signature Unkno Wn Restored from __doc__ "" "x.__repr__ () <==> repr (x)" "" Pass Def __setitem__ (self, I, y): # Real Si Gnature unknown; RestoreD from __doc__ "" "x.__setitem__ (i, y) <==> x[i]=y" "" Pass Def __sizeof__ (self): # real Signature Unknown Restored from __doc__ "" "d.__sizeof__ ()-size of D in memory, in bytes" "" Pass __hash__ = None

  

Basic data types in Day02python-lists and Ganso and dictionaries

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.