Use print inside lambda

后端 未结 4 1011
清歌不尽
清歌不尽 2021-01-20 02:35

I am trying to use print inside lambda. Something like that:

lambda x: print x

I understand, that in

4条回答
  •  一向
    一向 (楼主)
    2021-01-20 03:27

    You can import print_function from the __future__ and use it as a function like this

    from __future__ import print_function
    map(print, [1, 2, 3])
    # 1
    # 2
    # 3
    

提交回复
热议问题