one difference of python3 from python

来源:互联网 发布:天仕博软件 编辑:程序博客网 时间:2024/05/16 01:16

Python 2.7.3

>>> s = 'abcdef'

>>> for i in [None] + range(-1, -len(s), -1):
...    print s[:i]
...
abcdef
abcde
abcd
abc
ab

a

Python 3.3.0

>>> s = 'abcdef'

>>> for i in [None] + range(-1, -len(s), -1):
...     print(s[:i])
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: can only concatenate list (not "range") to list

0 0