To this topic you may have guessed what I will say next, hehe, right, that is to list these two different versions of the But not!
You'll find that Python has two major versions, Python2 and Python3, but Python is different from other languages, backward-compatible, and Python3 is backward-compatible, but most of the components and extensions are based on Python2, Here's a summary of the difference between
My Python self-learning Path 3: tuples and dictionary learning summary, the path to python
1. tuples
1. the Python tuples are similar to the list, except that the elements of the tuples cannot be modified.
The tuples use parentheses, And the list uses square brackets.
Creating tuples is simple. You only need to add ele
It's a bit more advanced here, and it's a little interesting to learn here, but I've seen the similarities with other languages.higher-order functions are called higher-order functions by passing other functions as parameters.defAdd (x, Y, f):returnF (x) +f (Y) Add (-5, 6, ABS)# One#anonymous function Python uses lambda to create anonymous functionssum =LambdaArg1, Arg2:arg1 +Arg2sum (10, 20)# -#The reduce
ReadLine () method to read line by row, reading one line at a time, and then moving the pointer to the beginning of the next line. The ReadLines () method stores the results of the read as a list, and when it is finished, the pointer moves to the next bit at the end of the file. Each line in the original file is a return element in the list. Append write using ' A ' mode, after opening the file, the pointer still refers to the file header, after the write () method is written into the string, t
;>> 1 2 3>>> >>> x,y=>>> 2 1 3
What we do here is sequential unpacking-Unlocking the sequences of multiple values and placing them in the sequence of variables. A more vivid expression is as follows:
>>> values=1,2,3>>>1, 2, 3>>> x,y,z=>>>1>>>2>>>3
4. chained assignment
Chained assignment is a shortcut to assign the sa
#!/usr/bin/python3#basic syntax and data types for Python#a row in Python3 has multiple statements, separated by semicolons (;)Print("AAA") ;Print("BBB")#basic Data types, removing long typesPrint(type (1))Print(type (1.0))Print(type ("Str"))#allow multiple variables to be assigned continuouslyA=b=c=1Print(a,b,c) a,b,c=1,2,"BB"Print(a,b,c)#6 kinds of standard data types#number (numeric)#string (string)#List
1 defNow ():2 Print('Hello')3 4 ImportFunctools5 6 deflog (func):7 @functools. Wraps (func)8 defWrapper (*args,**kw):9 Print('begin call%s ():'% func.__name__)Ten func_tmp=func (*args,**kw) One Print('End Call%s ():'% func.__name__) A return func_tmp - returnWrapper2, a simple summary functools.partial of the role of a function is to fix some parameters (that i
Python provides a standard module, called Pickle. With it you can store any Python object in a file, and then youAnd you can take it out in its intact. This is referred to as a persistent storage object.There is another module called Cpickle, which is functionally identical to the Pickle module, except that it is written in C, soMuch faster (1000 times times faster than pickle). You can use either of them,
it several times. When I wrote 100, it was displayed from the page where it was located, but if I wrote 10, is displayed on the 1st page), Rn = 20 indicates that 20 entries are displayed on each page, ie = UTF-8 indicates the encoding format, USM = 4 does not understand what it means, I tried it for 1, 2, and 3, but no changes were found. rsv_page = 1 indicates the page number. If you want to download the above page, you can simply use the above URL
Python-an object-oriented language with the largest characteristics of encapsulation, inheritance, and polymorphism.Encapsulation: Encapsulation can be used directly without caring about how the object is built. Is the principle of hiding excess information from other areas of the global scopeTo define a class:1>>>classPerson ():2 defSetName (self,name):3Self.name =name4 defGetName (self):5 returnSelf.name6 defgreet (self):7
file Os.rename ("Oldname", "newname") Rename File/directory Os.stat (' path/ FileName ') Gets the file/directory information os.sep the operating system-specific path delimiter, win under "\ \", Linux under "/" os.linesep the current platform using the line terminator, win under "\t\n", Linux "\ n" OS.PATHSEP the string OS used to split the file path. The Name string indicates the current usage platform. Win under "NT", Linux under "Posit" Os.system ("Bash command") run shell command, direct di
'% (DH, h))ifDH! = hElseOpen (Os.path.join (IPP, PF),'WB'). Write (by)2.3 If clicking perference appears, the package Control option succeeds or the installation fails.Three, configuration packageClick on the new package Control , enter installEnter the installation interface: I install two plugins myself:1.SideBarEnhancements = Sidebar Management2.Anaconda (the strongest Python IDE plugin)Four, if the
has a shortcut to disable the partial pylint check by inserting a #pylint: disables the comment. Anacondais currently the best Python auto complement and syntax hint plugin in Sublime 3, and provides plug-ins in the IDE such as "Jump to Definition", "Find using", "Show Document", "Auto rename".sidebarenhancementsprovides enhanced functionality for the default sidebar. Sublime's sidebar can be paged out usi
correctly.6. Default parameters(1) Set the default value directly when defining:def zjhfunction (a=1,b=2):XxxWhen called, the parameter can be empty, or the desired value is assigned.7. Collecting parameters(1)def zjh (*params):XxxZjh (' Zjh ', 2.3)Run time: Package The parameters Cheng Yuanju the params. The output length (here is the number, starting from 1) is 4.Params[i] represents the first element.(2) Collect parameters and customize parameters
real parameter at most. Therefore, the form parameter that has been passed in by the location parameter cannot be used as a keyword parameter in the same call.
In short, because Python's function parameter definitions and calling methods are too flexible, it is easy to confuse people at first. However, you will find Python easier.3.3 function documentation
In C #, you can use the XML mark of the document to annotate the function. In this way, in IDE
Chapter 6 abstract function parameters, Python Functions
6.1 create a function
A function can be called (which may contain parameters, that is, the values placed in parentheses). It performs a certain action and returns a value. In general, the built-in callable function can be used to determine whether the function is callable:
>>> x=1>>> y=math.sqrt>>> callable(x)False>>> callable(y)True
Def statement for
://i.cnblogs.com/EditPosts.aspx?opt=12. The Print status code is 200 because the Requets library automatically handles the redirect request.3. After the redirected address is automatically processed, we cannot get to the next step, we can set a parameter prohibit redirect: Allow_redirects=false ( =false is allow redirection, and then you can see that Status_code is 302. Third, get redirect address1. After the first request,
Basic Python knowledge (3): Basic python knowledgeI. Functions
Def function name (): Code encapsulated by the function...
Def is short for define
Other Python files can be introduced and called.
DefinitionAnd other code including comments keep two blank lines
PycharmDebuggingHour
NotePress Ctrl + Q to view th
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.