Is Python 2 or Python 3 better to learn Python? Liuxingyuan Classroom tells you!

thumbnail

Someone recently asked the editor: Is it better to learn Python using Python2 or Python3? What is the difference between Python3 and Python2? We together look.

There is a big difference between Python3 and Python2.

Python2 and Python3 are two versions of Python respectively. Python3 is an upgraded version, and many programs designed for earlier Python versions cannot be executed normally on Python3.0.

  1. Python2 can use parentheses or a space to separate the print content, such as print 'hi'; Python3 uses print to include the print content in parentheses, such as print('hi');

  2. Python2 range(1,10) returns a list, and Python3 returns an iterator to save memory;

  3. Ascii encoding is used in Python2, and uft-8 encoding is used in Python3;

  4. In Python2, Unicode represents a string sequence, and str represents a byte sequence; in Python3, str represents a string sequence, and byte represents a byte sequence;

  5. Chinese is displayed normally in Python2, and the coding statement is introduced, which is not required in Python3;

  6. The raw_input() function is used in Python2, and the input() function is used in Python3.

The above is all the content shared this time. If you want to learn more Python skills, please continue to pay attention to Liuxingyuan Classroom!

Latest Programming News and Information | GeekBar

Related Posts