I. PY2/PY3 differences
-Encode & string
String:
Py2:
Unicode v = u "root" is essentially stored in Unicode (Universal code)
(str/bytes) v = "Root" is essentially stored in bytes
Py3:
str v = "Root" is essentially stored in Unicode (Universal code)
Bytes V = b "Root" is essentially stored in bytes
Coding:
Py2:
-ASCII
File header can be modified: #-*-encoding:utf-8-*-
Py3:
-Utf-8
File header can be modified: #-*-encoding:utf-8-*-
Note: How are files stored?
-Inheritance
PY2: Classic class/New class
PY3: New Class
-Range
Py2:range/xrange
Py3:range
-Input
PY2:V1 = raw_input (' Please enter user name: ')
Py3:v2 = input (' Please enter user name: ')
-Print
Py2:print ' xx '
Py3:print (123)
Two. List-generated
v = [Lambda x:x + i for I in range (10)]
Print (v) # 10 A list of memory addresses
Three. Network programming
1. My computer has a network card, the network card has a MAC address
2. I plug in a network cable, the DHCP service in the router or switch automatically assigns an IP address to me.
ip:192.168.13.84
IPv4
00000000.00000000.00000000.00000000
0~255 0~255 0~255 0~255
IPv6
00000000.00000000.00000000.00000000.00000000.00000000
Subnet Mask: 255.255.255.0
192.168.13.84
255.255.255.0 # can also be 255.255.254.0
192.168.12.84
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.
Gateway ip:192.168.13.1
Intranet, metropolitan area network, WAN:
Broadcasting
Unicast
Broadcast Storm
ARP protocol
Dns
Network connection:
-Domain Name resolution
Www.bitfinex.com 127.91.64.33
-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 bitifnex.com
Linux/mac Computer:
/etc/hosts
DNS server: Top 13 DNS servers worldwide
Www.bitfinex.com 127.91.64.33
Business:
A. Rent a server + public network IP
B. Rent a domain name
Domain +IP parsing
Four. Socketserver
Note: You can use multithreading if you want to improve efficiency.
Five. Threads
Import Timeimport threadingdef Task (n): print ( ' Start task: ', ' n ') print (' ') S executed: '%n) while True: name = input ("Please enter task:") t = Threading. Thread (target=task,args= (name,)) T.start ()
Six. UUID Module
Import Uuidv = str (UUID.UUID4 ()) print (v)
Py2/py3 differences, list generation, network programming, Socketserver, threading, UUID modules