The main difference Python2.x and Python3.x of (turn)

python2.x and python3.x versions are very different, in addition to the name dependencies vary widely, the major differences are summarized as follows:
. 1) print function
Python3 in parentheses print function is necessary, Python 2 is optional .

2) read the keyboard input aspect
Python3 leaving only input () function, and all of the input data as a string; Python 2 also supports row_input () function, input () function during the processing of the input digital, if the input numbers quoted , then as a string, or as digital processing.

3) divisible
Python3, the operations are divisible into a floating point number conversion process types, Python 2 divides the operation performed rounding operation.

. 4) represents the Unicode
Python2 data stored as Unicode encoding format, the U-character string to be marked, Python3 default encoding format is stored as Unicode.

5) xrange () function
Python2 there range () and xrange () function, wherein xrange () return a list of needed size to save on memory usage, will Python3 xrange () function to rename range () function, and Python3 .2 and higher versions support sections.

6) next () and .next () function
Python2 support for the two functions, Python3 only supports next () function.

7) Python2 transcoding tool 3: 2to3
2to3.py script will be typically installed in the tools / scripts folder. It reads Python2.x source code, and application of a series of fix will turn it into a valid Python3.x codes; as: 2to3 -w test.py.
---------------------
Author: raxanne
Source: CSDN
Original: https://blog.csdn.net/zylove2010/article/details/79594000
Disclaimer: This article as a blogger original article, reproduced, please attach Bowen link!

Guess you like

Origin www.cnblogs.com/liehen2046/p/11067552.html