The difference between # python2 and python3 summary.

1, print ---- unimportant

  py2:print'xx'

  py3:print('xx')

 

2, an important inheritance -----

  py2: Classic / new class

  py3: new class

 

3, coding & string: ---- important

  String:

    py2: unicode v = u "xxx" stored in unicode with essentially

         (Str / bytes) v = "xxx" stored in the nature of bytes

    py3: str v = essentially "xxx" stored in unicode with

         Essentially bytes v = b "xxx" stored in bytes

  coding:

    py2: default ascii

    py3: utf8 default

4, input ---- unimportant

  py2:v1 = raw_input('xx:')

  py3:v1 = input('xx:')

 

5, range: ---- less important

  py2:range/xrange

  py3: range --- (py3 range equivalent to the range of xrange.py2 Py2 range corresponding to the length is created directly in memory)

Guess you like

Origin www.cnblogs.com/cbslock/p/11307279.html