The difference between Python2 and Python3/multithreading in the Network programming/socketserver module

Source: Internet
Author: User

A. Knowledge Point supplement:

1. Explanatory and compiled languages

Compiled (there are currently two explanations):

First compile the code into machine code, machine register to run: C language

First compile the code into XXX---computer to find the virtual machine execution code--machine code to the computer to do: C, java,c#

Explanatory type:

Edge Interpretation Side Execution

Scopes in 2.Python

A function in Python is a scope

3. Specify the format of the tuple to be written later:

v = (All-in-all,)

1. The function in Python is a scope i=0 forIinchRange (10):    PassPrint(i) Results:9deffunc (): forIinchRange (10):        Passfunc ()Print(i) Result: Error2. List-generated Val= [LambdaX:x+i forIinchRange (10)]ret= Val[3] (6)Print(ret) Results:15Val= [Lambda: X forXinchRange (10)]ret= Val[3]()Print(ret) Results:9
View Code

Two. The difference between Python2 and Python3

1. Encoding & String

String:

Python2:

Unicode v = u "root" is essentially stored in Unicode (Universal code)

(str/bytes) v = "Root" is essentially stored in bytes

Python3:

str v = "Root" is essentially stored in Unicode (Universal code)

Bytes V = b "Root" is essentially stored in bytes

Coding:

Python2:

Ascii

File header can be modified: #-*-Encoding:utf-8-*-

Python3:

Utf-8

File header can be modified: #-*-Encoding:utf-8-*-

Note: How is the file stored?

2. Inheritance

Python2: New class/Classic class

Python3: New Class (Inherits object)

3. Scope

Python2:range/xrange

Python3:range

4. Enter

PYTHON2:V1 = raw_input ("Please enter user name:")

Python3:v2 = input ("Please enter user name:")

5. Print:

Python2:print "XX"

Python3:print (123)

Three. Network programming

1.PC has a network card, the network card has a MAC address

CMD--Config/all Physical address is your MAC address

2. The DHCP service in the router or switch in the LAN automatically assigns the IP address to US

DHCP service: To say the popular point, you are in your network card local connection set to "Automatically obtain IP address", and DHCP is for your network card that connection provides automatic configuration IP address, subnet mask, gateway, DNS and other information of a service agreement, run this protocol is called the DHCP server

IP: protocol designed to communicate with each other in connection with a computer network

IPV4: The fourth edition of the Internet Protocol is also the first to be widely used, constituting the current Internet even if the basis of the Protocol, with 32-bit 0/1 sequence to represent, divided into four eight-bit sequence, each segment of the range is: 0~255

00000000.00000000.00000000.00000000

0~255 0~255 0~255 0~255

IPV6: Used to design alternative versions of the current version of IPV4, using 16 binary to represent, also according to 8-bit segmentation, between segments and segments with ":" Split

00000000.00000000.00000000.00000000.00000000.00000000

Subnet mask: The subnet mask is a 32-bit address that is used to mask part of an IP address to differentiate between the network identity and the host identity, and whether the IP address is on a local area network or on a remote network, and cannot exist alone, and must be combined with an IP address

192.168.13.84
255.255.255.0

Gateway IP: If two IP addresses, not the same network segment, this time, to access the IP address of another network segment of the computer (also the IP address), you need a gateway address. The gateway address is the address of the exit, and the gateway address is your nearest exit address. The gateway address is always the same network segment as the IP address of your computer

192.168.13.1

LAN, metropolitan area network; WAN    broadcast unicast broadcast Storm ARP protocol
View Code

3.DNS Server

Network connection:

-Domain name resolution www.luffycity.com 47.95.64.113

Www.oldboyedu.com 101.200.195.98

-Connection

SK = Socket.socket ()

Sk.connect (' 47.95.64.113 ', 80)

...

The question is, where is the correspondence between domain name and IP?
Local:
Win Local computer:
C:\Windows\System32\drivers\etc\hosts
11.11.11.11 luffycicy.com
Linux/mac Computer:
/etc/hosts

DNS server: Top 13 DNS servers worldwide

4. Summary:

(1). DHCP, automatic bit LAN content the computer assigns IP.
(2). Gateway, the port in the router where the switch is connected.
(3). Decimal representation of ip,4 points 192.11.111.11
(4). Subnet mask,
ip:192.168.13.99
Mask: 255.255.255.0
The number of blocked IP digits is used as a network segment.
The part that is not blocked as a variable value.
(5). LAN/metropolitan area network/WAN
(6). ARP protocol
(7). DNS

111

The difference between Python2 and Python3/multithreading in the Network programming/socketserver module

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.