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
>>> 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
相关文章推荐
- one difference of python3 from python
- Computing the Relative Path from One Directory to Another(Python cookbook 2-22)
- Recipe 1.5. Trimming Space from the Ends of a String(Python Cookbook)
- yum 运行时提示There was a problem importing one of the Python modules required to run yum. The error lead
- 19. Remove Nth Node From End of List Leetcode Python
- leetcode 【 Remove Nth Node From End of List 】 python 实现
- How to (how to refresh/redirect the contents of one frame from another frame )
- leetcode 019 Remove Nth Node From End of List (Python)
- Is it possible to get the difference from two dynamic arrays regardless of their order?
- 解决yum升级的问题“There was a problem importing one of the Python modules”
- what is the difference of select single and select up to one row in abap
- New release of code samples from Microsoft All-In-One Code Framework (2011-6-19)
- Microsoft SQL Server 2008 R2 XML处理 One solution is to increase the number of characters retrieved from the server for XML data.
- One of the difference between JDK1.6.0 and JDK1.7.0
- 【LeetCode with Python】 Remove Nth Node From End of List
- LeetCode 19 — Remove Nth Node From End of List(C++ Java Python)
- A bit of socket code from python
- one mail for difference between LOCAL_LDLIBS and LOCAL_SHARED_LIBRARIES of Android
- One of the most recognizable bags from the line is the Michael Kors Hamilton
- Actor::updateMassFromShapes: Compute mesh inertia tensor failed for one of the actor's mesh shapes!