Alibabacloud.com offers a wide variety of articles about dict comprehension python 3, easily find your dict comprehension python 3 information here online.
. Generator:Only the corresponding data is generated during the call, and there is only one _ next _ () method.
If the list elements can be calculated by some algorithm, can we continue to calculate the subsequent elements in the loop process? In this way, you do not need to create a complete list to save a lot of space. In Python, this type of computing mechanism is called a Generator ).
Creation method:1) The simplest is to change [] of a list gener
1. Data typeDigital int is mainly used for computational purposes and is not used in many ways. e.g. 1 100 1000boolean bool has two types, true,false. The correct condition of the reaction. If True FalseThe string str is used to store a small amount of data for operation. Like ' I am a boy ' a lot of children 'The list of lists stores a large amount of data. such as [All-in-a--"Thai, ' 12353234 ', [up and Down]]Ganso A tuple- read-only list. such as ("third party",)Dictionary
Cluster Type
Cluster Type
List
Meta-group
Dictionary
Collection
List
Tuple
Dict
Set
1. ListThe type of list, which is ordered, has an index, and the content and length can be changed. To create a list, you can use the [] direct notation, with each element in the list separated by commas.Common actions for lists(1) Sectioning of elementsnames=["Zhangfei","Guanyu"
Python built-in data structures
First, the numerical type
1. Data type classification: int: integerPython3 int is a long integer with no size limit and is limited by the size of the memory areaint (x) returns an integerfloat: floating pointThere are integers and fractional parts. Supports decimal and scientific notation notation. Only double-precision.Float (x) returns a floating-point numberComplex: pluralThere are real and imaginary part
Data:The elements of the list are variable and are created with a [] or list ().The elements of the Ganso are immutable, created with () or tuple ().The elements of the collection are not repeatable and are created with the {} or set ().The dictionary is stored k-v, created with dict () or {}.Del: Delete data structure element or variable by index===================================================ListList.append (x) = = = A[len (a):]=[x]List.extend (L
contrast to all (), is null in any () with an iterated object value of false, a value of true is true, all false is False6) Bin (), Oct (), Hex ()Returns binary, octal, hex7) Callable ()Determines whether the object can be called8) Chr ()Converting character encodings (numbers) to characters9) Ord ()Corresponds to Chr (), converting characters to encodingsTen) Complex ()Functions that generate complex numbersDir ()View the contents of a member in this objectDivmod ()Pass in two parameters, retu
Print(ex)exceptException as ex:#Exception matches all the same #executes when an error other than ValueError is detected Print(ex)Else: #executes when the main code block finishes executing Passfinally: #regardless of whether the main code block has an error, execute PassProactively triggering exceptionsTry : Raise Exception (' active error ')except Exception as E: Print (e)Custom exceptions class MyException (Exception): Span style= "color: #0000ff;" >def __ini
'])################################################################Import Urllib.requestImport JSONContent=input ("Please enter what you need to translate:")Url= ' Http://fanyi.youdao.com/translate?smartresult=dictsmartresult=rule 'data={}data[' I ']=contentdata[' from ']= ' AUTO 'data[' to ']= ' AUTO 'data[' Smartresult ']= ' dict 'data[' client ']= ' Fanyideskweb 'data[' salt ']= ' 1520575049536 'data[' sign ']= ' 4514C46C320493BA8C034EAA8D9DECAF 'd
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.