[英]How to make a smaller list of tuples from a large list of tuples?
I have a large list with about 50 or 60 tuples. 我有大约50或60个元组的大清单。 In the form:
形式:
a=[('a', 50), ('b', 46), ('c', 41), ('d', 35) ...]
I want a new list with only the first 20 tuples in the list. 我想要一个仅包含列表中前20个元组的新列表。 Like:
喜欢:
b=[('a', 50), ('b', 46), ('c', 41), ('d', 35) ... ,('aa', 10)]
可以使用列表切片来完成:
b = a[:20]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.