Alibabacloud.com offers a wide variety of articles about dict comprehension python 3, easily find your dict comprehension python 3 information here online.
:333}
Set--DictMap 2 sets to a dictionary by Zip:
123456
Set1 = {1, 2, 3}Set2 = {' a ', ' B ', ' C '} print (dict (Zip (Set1, Set2)) # {1: ' C ', 2: ' A ', 3: ' B '}
SETSTR, setThe characters are first cut into tuples and then converted to collections.
1
Print (Set (' Hello ')) # {' L ', ' o ', ' e
variable, which is actually a variable pointing to the function. A variable can point to a function, and the argument of a function can accept a variable. Then a function can receive another function as a parameter, which is called the higher order function. If you point a python built-in function name to another object, you cannot call the function through the variable name and error. The sample code is as follows: >>> ABS ( -10)10>>> abs in functio
, which is actually a variable pointing to the function.A variable can point to a function, and the argument of a function can accept a variable. Then a function can receive another function as a parameter, which is called the higher order function.If you point a python built-in function name to another object, you cannot call the function through the variable name and error. The sample code is as follows:>>> ABS ( -10)10>>> abs in function abs>>>> f
This blog collects the pits encountered from Python 2 to Python 3 due to different writing. Gives a written notation that Python 2 and Python 3 are compatible. 1. How to be compatible with raw_input () and input ()
Python Reading Notes-Chapter 3, chapter 4, python Reading NotesChapter 3 1. string formatting >>> format = "hello % s world" >>> values = ('World', 'hot ') >>> print format % values # You can also receive a single string or use the % f % d type. When matching multiple parameters with c's printf, you should use parenthe
There are a lot of python-specific things, very interesting, previously only contact C, C + +, Java, Javascript, did not expect to play like this#------------------Slice--------------------##slice slices to cut out another array from an arrayLi = List (range (10))Print(LI)#[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]#[Start, End, Step] | | (start-end) to be consistent with the sign of stepPrint(Li[2:5])#[2,
Python learning path 3: python learning pathContent of this section:
Common string processing.
Format the output string.
String replacement.
Conversion of strings and binary data.
Dictionary operations
String operation
Common string processing
Name = 'vector 'print (name. capitalize () # print (name. count ('E') # determine the number of print (name. cente
...1.In syntax, the return of a tuple can omit parentheses, and multiple variables can receive a tuple at the same time, assigned to the corresponding value by location,So, the Python function returns a multivalued value that actually returns a tuple, but it's easier to write.2.Defining default parameters Keep in mind that the default parameter must point to the immutable object!3.
differences between function parameter 3.2.1 C # And Python in function parameter definition
There are four types of method parameters in C:
(1) Value parameters do not contain any Modifier(2) The referenced parameter is declared with a ref modifier (there is no corresponding definition in Python)(3) output parameters are declared with the out modifier (this is
Python learning diary 3 variable 2, logical judgment, for loop, python variable
Review the questions that occur when you write a quiz code.
The condition in the While statement. It should be when result = false and answer = input. If answer = input () is written outside the while clause, too small will be output as it was yesterday.
There is also the if statement
number
Methods and descriptions
1
cmp (tuple1, tuple2) Compares two tuple elements.
2
len (tuple) The counts the number of tuple elements.
3
max (tuple) The returns the maximum value of the element in the Tuple.
4
min (tuple) The returns the minimum value of the element in the Tuple.
5
tup Le
modifiers(2) The reference parameter is declared with a ref modifier (there is no corresponding definition in Python)(3) Output parameters declared with out modifier (not required in Python, because functions can have multiple return values)(4) Array parameters are declared with the params modifierThere are also four types of function parameters in
Python [3]-dictionary dic And set, python dictionary dicsetI. dictionary dict
Dict is stored as a key-value pair. The creation method is to use braces {} and separate the key and value with a colon.
>>> d={'chen':60,'zhang':80}>>> print d{'chen': 60, 'zhang': 80}
Assignment
In order not to take in too much of a burden, Python 3.0 did not consider downward compatibility when designing. As a result, many programs designed for early Python versions cannot perform properly on Python 3.0.
To take care of the existing program, Python 2.6, as a transitional version, basically uses the synta
automatically recognize a byte sequence as a Unicode string by:
From __future__ import unicode_literalsprint (repr ("Fish"))
The division operator "/" always returns a floating-point number within Python 3.x. In Python 2.6, it is determined whether the dividend and divisor are integers. If an integer returns an integer value, which is equal to divisible, the flo
indexer and slice. For the indexer. netProgramFor example, in list and tuple, we can use the list [Index] method to access the values in the list. This is very similar.. Net indexer. Slice is a part of the returned list.For example>>> A = [1, 2, 3, 4, 5]>>> A [1: 3][2, 3]Through a [], we return the sublist from the second element to the fourth element in list A.
= set ('Abracadabra') -b = Set ('Alacazam') - the Print("set-a =", a) - Print("set-b =", B)Wuyi the Print("A-B =", A-B)#the difference between A and B - Wu Print("A | b =", a | b#the set of A and B - About Print("A B =", A B)#intersection of A and B $ - Print("a ^ b =", a ^ b)#elements in A and b that do not exist at the same time - - """Word typical""" A #Key-value pairs are stored in the form of a JSON-like representation of a middle key value +Di
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.