您的位置:首页 > 编程语言 > Python开发

one difference of python3 from python

2014-12-09 19:38 337 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐