Python和函数式编程:是否有apply()函数?

栏目: 编程语言 · 发布时间: 7年前

内容简介:翻译自:https://stackoverflow.com/questions/32249197/python-and-functional-programming-is-there-an-apply-function
Scala 具有 apply()

功能.

我是 Python 新手,我想知道如何编写以下单行代码:

(part_a, part_b) = (lambda x: re.search(r"(\w+)_(\d+)", x).groups())(input_string)

我会感觉更好,比如:

(part_a, part_b) = input_string.apply(lambda x: re.search(r"(\w+)_(\d+)", x).groups())

从FF的角度来看,我错了吗? Python中有这样的结构吗?

编辑:我知道糟糕挑选的片段.

在编写Haskell时编写Haskell.编写Python时只需编写Python:
part_a, part_b = re.search(r"(\w+)_(\d+)", input_string).groups()

翻译自:https://stackoverflow.com/questions/32249197/python-and-functional-programming-is-there-an-apply-function


以上所述就是小编给大家介绍的《Python和函数式编程:是否有apply()函数?》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Single Page Web Applications

Single Page Web Applications

Michael Mikowski、Josh Powell / Manning Publications / 2013-9-30 / USD 44.99

Code for most web sites mostly runs on the server. When a user clicks on a link, the site reacts slowly because the browser sends information to the server and the server sends it back again before di......一起来看看 《Single Page Web Applications》 这本书的介绍吧!

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

html转js在线工具
html转js在线工具

html转js在线工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具