A list of Python Data Types

Source: Internet
Author: User

A list of Python Data Types

I. Basic Data Types

Integer: int
String: str (Note: \ t is equal to a tab key)
Boolean value: bool
List: list (set of elements)
List []
Ancestor: tuple
Ancestor use ()
Dictionary: dict
Note: All data types exist in the desired class columns.

Ii. list all data types:

Basic operations:

• Index
• Slicing
• Append
• Delete
• Length
• Slicing
• Loop
• Include

Listclass list (object): "list ()-> new empty list (iterable)-> new list initialized from iterable's items" def append (self, p_object): # real signature unknown; restored from _ doc _ "L. append (object)-> None -- append object to end "(L. append (object)-> -- no object is appended to the end) pass def clear (self): # real signature unknown; restored from _ doc _ "L. clear ()-> None -- remove all items from L "(L. clear ()-> NO. Extract all items from L) pass def copy (self): # real signature unknown; restored from _ doc _ "L. copy ()-> list -- a shallow copy of L "" (L. copy ()-> list-L shortest copy) return [] def count (self, value): # real signature unknown; restored from _ doc _ "L. count (value)-> integer -- return number of occurrences of value "" (L. count (value)-> integer, number of occurrences of returned values) return 0 def extend (self, iterable): # real si Gnature unknown; restored from _ doc _ "" L. extend (iterable)-> None -- extend list by appending elements from the iterable "" (L. extend (iterable)-> None -- add the Meta from the iterable extension list) 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. (L index (value, [start, [do not])-> integer, returns the first index value. It puts forward the value of ValueError if it does not exist .) "" Return 0 def insert (self, index, p_object): # real signature unknown; restored from _ doc _ "" L. insert (index, object) -- insert object before index "" (l insert (index (object) -- insert object index before) pass def pop (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 empty or index is out of range. (L. pop (INDEX)-> project -- delete and return the item index (default ). It is proposed that if the IndexError list is null or the index range .) "Pass def remove (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 value that appears for the first time. It puts forward the value of ValueError if it does not exist .) Pass def reverse (self): # real signature unknown; restored from _ doc _ "L. reverse () -- reverse * in place * "pass def sort (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 _ (sel F, * 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 (iterable)-> new list initialized from iterable's items # (copied 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

Iii. 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) # number of times that the specified count character appears name_list = ["zhangyanlin", "suoning ", "nick"] name_list.append ('zhang') name_list.append ('zhang ') print (name_list.count ('zhang') # extended, batch add data name_list = ["zhangyanlin", "suoning", "nick"] name = ["aylin", "zhang", "yan ", "lin"] name_list.extend (name) print (name_list) # index locate the character location name_list = ["zhangyanlin", "suoning ", "nick"] print (name_list.index ('Nick ') # insert, insert the value name_list = ["zhangyanlin", "suoning ", "nick"] name_list.insert (1, "zhang") print (name_list) # pop removes the last element from the original list and assigns the value to another variable name_list = ["zhangyanlin ", "suoning", "nick"] name = name_list.pop () print (name) # remove, only remove the first name_list = ["zhangyanlin", "suoning ", "nick"] name_list.remove ('Nick ') print (name_list) # reverse name_list = ["zhangyanlin", "suoning", "nick"] name_list.reverse () print (name_list) # del Delete the element and delete name_list = ["zhangyanlin", "suoning", "nick"] del name_list [] print (name_list) between 1 and 3)

Iv. Index

name_list = ["zhangyanlin","suoning""aylin""nick"]print(name_list[0])

5. Slicing

name_list = ["zhangyanlin","suoning""aylin""nick"]print(name_list[0:2])

6. Total length len

name_list = ["zhangyanlin","suoning""aylin""nick"]print(name_list[1:len(name_list)])

VII. for Loop

name_list = ["zhangyanlin","suoning""aylin""nick"]for i in name_list:  print(i)

The above is the complete list of Python data types provided by the editor. I hope you can provide more support ~

Related Article

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.