the difference between Python 2 and Python 3
recently began to learn Python, the process of continuous learning to the difference between the two, in order to facilitate the review, so write here, the content will be constantly updated
1, Encoding: Python2 's default encoding is ASCII, so the default is not supported in Chinese, if you want its support must add #-*-Coding:utf-8-*-and Python3 's default encoding is Utf-8, that is, in writing Python can be directly used in text;
2. A clearer distinction is made between text and binary data in Python3, text is always Unicode, represented by the STR type, binary data is represented by the bytes type, and Python3 does not mix str and bytes in any implicit way, So you can't stitch strings and byte packets, or search for strings in a byte packet (or vice versa), or pass a string into a function with a byte packet (or vice versa);
3, Python 2.x to 2020 will no longer have the support of the official website;
4, Python 2 of the input raw_input was deleted, using input to replace;
5. The print statement in the Python2 is deleted and replaced with the print () function;
6. In Python2 socket, between the server and the client can transmit strings, in the Python3 can only transfer binary encoding, so for STR to carry out encode () operation;