DescriptionEnumerate () is a python built-in function:
For an iterative (iterable)/Ergodic object (such as a list, string), enumerate makes it an index sequence that can be used to obtain both the index and the value
More for counting in a
Import of Packagesseveral ways to import
Import Package Name1 Import Time 2 time.time ()
Import package name, package name1 Import Time,sys 2 time.time () 3 Sys.path
From Package name Import module name1 from Import Time 2 Time ()
From
Flat Dictionary目标 {‘a‘:{‘b‘;1,‘c‘:2},d:{‘e‘:3,f:{g:4}期望 {‘a.b‘:1,‘a.c‘:2,‘d.e‘:4,‘d.f.g‘:4}dic = {‘a‘:{‘b‘:1,‘c‘:2},‘d‘:{‘e‘:3,‘f‘:{‘g‘:4}}}dic1 = {}def fn(dic:dict,dic1key=‘‘): for k,v in dic.items(): if isinstance(v,dict):
Python commonly used methods are generally built-in functions, or inherited from the method of object, is said to be a tool class method, but I sometimes encounter some problems, some methods can be like a tool to view certain information, more
Name spaceaka Name space, as the name implies is the place to store names, what name? For example, if the variable x=1,1 is stored in memory, where is the name x stored? Namespaces are where the name X and 1 bindings are storedA total of 3
Single underline, double underline, and tail-to-bottom double underline description:
__foo__ : Defines a special method, typically a system-defined name, similar to __init__ () and so on.
_foo : A variable of type
custom paging, copy introduction can be used1 classpagination (object):2 def __init__(self,totalcount,currentpage,perpageitemnum=10,maxpagenum=7):3 #total number of data4Self.total_count =TotalCount5 #Current Page6 Try:7v
Unit testing is a test that is used to verify correctness of a module, a function, or a class.Unit testing using the UnitTest module1) test the functionHere is a simple function that receives the first and last name and returns a neat
Camp had a lot of holes in the Python2 code.Understand the coding of pyhon2There are only two types of Python2 string: str type: b ' XXX ' is also a str type, which is the encoded type, Len () computes the Unicode type in bytes: Len () is calculated
The combination of objects is also called nesting or modeling, which is accomplished by assigning objects to each other in different classes, as in the following exampleClass School (): def __init__ (self,name,addr): self.name=name
Python-oriented reflection in objects: manipulating Object-related properties in the form of strings. All things in Python are objects (you can use reflection)GetAttr # to find a member in the object, based on the form of a string.Hasattr #
1. Coding ParadigmProgramming is the process by which programmers use a specific syntax + data structure + algorithm to tell a computer how to perform a taskWhen programming is likened to martial arts, programming is the genre of martial art, and
This document is used to record the standard modules in Python and is updated at any time.Decimal module (solving fractional loop problems):>>> Import Decimal>>> a = decimal. Decimal (' 10.0 ')>>> b = Decimal. Decimal (' 3 ')>>> A/bDecimal (' 3.33333
Insert Sort algorithm Summary:The core of the insertion algorithm is that each time it loops to a number, it is considered that the sequence before the number is in order, inserting a number into an ordered sequence that is already sorted, and thus
Three main object-oriented features: encapsulation, inheritance, and polymorphismFirst, the packageEncapsulation, as the name implies, encapsulates the content to a place where it can be called directly to the content that is encapsulated somewhere.-
python basic Knowledge Directory function
The initial knowledge of the function
Name space
Application of function name and closure
Built-in function
Built-in functions overview
Map () Map function
Python Basic
What data type? int 1, 2, 3 is used to operate the FLOAT 1.2 STR is used to store certain information "" ' List =[1,2, 3 "yes", is] used to store a large amount of information Touple (1, 2, 3,) is used to store immutable lists,
One.Isinstance (check whether the first parameter is a descendants class of the second argument) class Base (object): Pass class Foo (Base): Pass = Foo () print (isinstance (obj1,foo)
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