Python reflection and built-in functions __str__, __repr__

One, reflectionVariables in reflection classVariables in reflection objectsVariables in reflection moduleReflect variables in this document1、Definition: use the variable name of string data type to get the value of this variable.For example:Name= 'xiaoming' print(name) # xiaoming print('name') # name Usually we want to get'xiaoming'This value is to be obtained by name, but if you want to use a string'name' Get this value?Reflection is needed.2、The scene of reflection application is to convert the received string to the name of the variable.1,input If the user input is a, the...

Binary application

1.Take a single 1. i&-i   The value returned is the number from the last forward to the first 1. int work(int x){int num=0;for(;x;x-=x&-x) num++;return num;} e.g.:luogu 1582Water reverse #include<bits/stdc++.h> using namespace std; int n,k,ans; inline int read(){ int x=0,f=1;char ch=getchar(); while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();} while(isdigit(ch)){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();} return x*f;} inline int sudo(int i){int ans=0;for(;i;i-=i&(-i)) ans++;return ans;} int main(){ n=read();k=read(); while(sudo(n)>k) ans+...

CSS Box Model box model

1.Summary 1.1Preface cssThe properties of the box model are:Content (content), fill (padding), border (border), boundary (margin);The box that we see in our daily life is also a kind of box that can hold things. It also has these attributes, so we use the box pattern to understand. The box in life shows: Content (content): something in a box. Padding: Foam or other earthquake-resistant additives added to a box for fear of damage to its contents. The border (border): the box itself. Margin: The boxes can’t all be stacked together, leaving some space for ventilation, but also for easy r...

Cable master (two points)

Cable master Time Limit: 1000/500 MS (Java/Others)     Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 30     Accepted Submission(s): 15 Special Judge Description Inhabitants of the Wonderland have decided to hold a regional programming contest. The Judging Committee has volunteered and has promised to organize the most honest contest ever. It was decided to connect computers for the contestants using a “star” topology – i.e. connect them all to a single central hub. To organize a truly honest contest, the Head of the Judging Committee has decree...

A simple introduction to digital DP

Time is not enough. Previously, I was misunderstood by the search code, thinking that the digital DP is actually a memory search. (Although the search is really comfortable and good to think) But later it was discovered that the standard format of digital DP is in fact preprocessing + DP…   Introduction of digital DP The digital DP is actually the number of numbers that you deal with in an interval that satisfies the conditions, but in general the interval is desperately large… For example, 1e9 is conscience. The general rule is 1e18 or even 1e10.n (n Usually 3 or 5 times.   G...

Object oriented three, constraint, encryption

One, constraint (similar to java interface py has no interface) Artificial constraints class BaseMessage(object): def send(self,x1): """ You must inherit BaseMessage, and then you must write the send method. Used to complete specific business logic.""" raise NotImplementedError(".send() It must be rewritten.") class Email(BaseMessage): def send(self,x1): """ You must inherit BaseMessage, and then you must write the send method. Used to complete specific business logic.""" print('Send mail') obj = Email() obj.send(1) Abstract class a...

Ubuntu16.04 configuration static IP (NAT mode) under VM virtual machine

Recently, in the process of writing a project on vm, you need to connect mysql on the virtual machine through Navicat on windows. it is found that the Ubuntu 16.04 system IP under the virtual machine is different every time you restart the virtual machine, resulting in the original Navicat configured connection can not be made.Use. So think of the need to configure a system in the VM will not change the ip, through the Internet to find relevant information, and according to their own practice, now will sort out the notes. You can configure static IP for VM virtual machines in a handover manne...