有没有办法在 python 中使用 reduce 函数连接字符串

Is there a way to concatenate strings using reduce function in python

li = ['Hello','my','name','is','Neo']
导入函数工具
打印(functools.reduce(λx,y:x+y,li)
尝试此代码时出现 EOF 解析错误
我无法找出发生这种情况的原因或如何解决此问题

您实际上只需要关闭打印函数的括号:

import functools
li = ['Hello','my','name','is','Neo']
print(functools.reduce(lambda x,y:x+y,li))