Home  >  Article  >  Backend Development  >  Is there a big difference between python2 and 3?

Is there a big difference between python2 and 3?

藏色散人
藏色散人Original
2019-07-02 14:27:293517browse

Is there a big difference between python2 and 3?

Is there a big difference between python2 and 3?

The difference between python2 and 3 is quite big.

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

Difference:

1. Python2 can either use parentheses or use a space to separate the print content, such as print 'hi'

Python3 uses print The print content must be included 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 utf-8 encoding is used in python3

4. Unicode in python2 represents a string sequence, str represents a byte sequence

Str in python3 represents a string sequence, and byte represents Byte sequence

5. In python2, Chinese is displayed normally, and the coding statement is introduced. It is not needed in python3.

6. In python2, it is the raw_input() function, and in python3, it is the input() function

Related recommendations: "Python Tutorial"

The above is the detailed content of Is there a big difference between python2 and 3?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn