0

我有一个字典列表,并且我有一个要应用于此列表并获得结果的函数。

>>> people = [
...     {
...         "name": "Taras Hryhorovych Shevchenko",
...         "dob": "March 9, 1814",
...     },
...     {
...         "name": "Ivan Yakovych Franko",
...         "dob": "August 27, 1856",
...     },
...     {
...         "name": "Vasyl Semenovych Stus",
...         "dob": "January 6, 1938",
...     },
... ]
>>> 
>>> def transform(people):
...     for person in people:
...         yield person.get("name").split()[0]
...     
... 
>>> list(transform(people))
['Taras', 'Ivan', 'Vasyl']

我可以使用RxPY得到这个结果吗?谢谢您的帮助。

4

0 回答 0