VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > 编程开发 > python3 >
  • python3教程之range方法在Python2和Python3中的不同(2)

本站最新发布   Python从入门到精通|Python基础教程
试听地址  
https://www.xin3721.com/eschool/python.html


Python2:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Python 2.7.10 (default, Aug 17 201819:45:58)
[GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.0.42)] on darwin
Type "help""copyright""credits" or "license" for more information.
>>> for in range(1,101):
...     print(i)
...
1
2
3
4
5
6
7
8
9
>>>

 

Python2直接生成列表,Python3需要配合list方法使用

Python3:

1
2
3
4
5
6
7
8
9
10
11
12
Python 3.7.2 (default, Feb 12 201908:15:36)
[Clang 10.0.0 (clang-1000.11.45.5)] on darwin
Type "help""copyright""credits" or "license" for more information.
>>> l = range(110)
>>> l
range(110)
>>> type(l)
<class 'range'>
>>> l2 = list(l)
>>> l2
[123456789]
>>>
相关教程