阅读背景:

Python -如何从列表中提取最后的x元素

来源:互联网 

If the length of a python list is greater than a given value (say 10), then I want to extract the last 10 elements in that list into a new list. How can I do this? I tried getting the difference between len(my_list) - 10 and use it as: new_list = [(len(my_list) - 10):] which does not workIf the length of a python list is greater than




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: