* * * * python2.7 version 2.7 only supports 65438+ 10/in 2020. Novices are advised to install Python version 3.
Terminal input difference
Python2.7:
(1)input () can automatically determine its type, that is, no matter what type of data is input, English characters without quotation marks will be judged as variables, and the corresponding variables will be found in the full text. If the str type must be enclosed in single or double quotes, otherwise the type is wrong and an error is reported.
(2) All data input by 2)raw_input () should be processed according to str type. If it is a plastic input, str should be converted into int when it is used, and forced conversion should be used (int).
Python3.6:
(1)input () All input data will be processed according to the str type. If it is a plastic input, str should be converted into int when it is used, and forced conversion should be used (int).
(2) No longer use raw_input ().
Related recommendation: Python video tutorial
Print difference
Python2.7:print is class, followed directly by the printed value.
Python3.6:print () is a function, and the printed value must be enclosed in parentheses.
Coding difference
Python2.7: By default, ASCII handles characters (strings are stored in 8 bits), so Chinese characters are preceded by #-*-encoding: utf-8 -*-.
Python3.6: Unicode (universal code, fixed 2-byte unified code, strings are stored in 16 bits) character set, utf-8 (dynamically variable 1-6 bytes, EN: 1 byte? Zh:3bytes) is the compression and optimization of Unicode, so it supports Chinese.
The difference between true division and exact division
Python2.7: with decimal point/means true division,% means remainder,//means floor division (the result is rounded off).
Python3.6: stands for true division,% stands for remainder,//stands for floor division (the result is rounded).
The difference between range and xrange
Python2.7:range () generates a list, and xrange () generates a generator.
Python 3.6: list (range (0 0,4)) list, range () generates generators, and xrange () is no longer used.
Open file difference
Python 2.7: both file () and open () can open files.
Python3.6: Instead of using file (), only use open () to open files.