The difference between Python2 and Python3

The difference between Python2 and Python3

1. P2 print does not require parentheses; P3 print(), the output content must be written in parentheses
2. P2 3/2 = 1;P3 3/2 = 1.5
3. range(function)
Python3 range() 函数返回的是一个可迭代对象(类型是对象),而不是列表类型, 所以打印的时候不会打印列表。

Python3 list() 函数是对象迭代器,可以把range()返回的可迭代对象转为一个列表,返回的变量类型为列表。

Python2 range() 函数返回的是列表。

Guess you like

Origin blog.csdn.net/rexxa/article/details/113838761