Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试通过更改从列表中提取值。该列表是来自 oracle 数据库的查询,具有以下值:-
22 22 22 22 22 22 23 23 23 23 22 22 22
您将如何对其进行编码,以便输出例如
22 23 22
我试过循环和唯一值,肯定有一个简单的方法吗?
使用itertools.groupby():
itertools.groupby()
from itertools import groupby for key, group in groupby(inputsequence): print key