当前位置:网站首页>当lambda没有输入时,是何含义?
当lambda没有输入时,是何含义?
2022-07-03 02:39:00 【strawberry47】
今天看代码的时候,看见一句代码[lambda: gym.make("SimulatedEnv-v0", ) for _ in range(args.training_num)] ;
用到了lambda,但是冒号前是空的,没有输入,输出是右边那一堆。我第一反应是这个lambda是不是可以不要哦
后来做了一下实验,发现还不能去掉呢!
def f(x):
return x * 100
print([f(3) for i in range(5)])
print([lambda: f(3) for i in range(5)])
前者是一堆结果的list,后者是一个函数的list:
[300, 300, 300, 300, 300]
[<function <listcomp>.<lambda> at 0x7fe7019acb80>, <function <listcomp>.<lambda> at 0x7fe7019acc10>, <function <listcomp>.<lambda> at 0x7fe7019acca0>, <function <listcomp>.<lambda> at 0x7fe7019acd30>, <function <listcomp>.<lambda> at 0x7fe7019acdc0>]
边栏推荐
- HTB-Devel
- sql server 查询指定表的表结构
- 【 tutoriel】 Chrome ferme les cors et les messages de la politique inter - domaines et apporte des cookies à travers les domaines
- My creation anniversary
- Build a private cloud disk cloudrev
- 为什么会选择框架?选择什么样的框架
- What does "where 1=1" mean
- Interview stereotyped version
- Gbase 8C system table PG_ auth_ members
- [fluent] JSON model conversion (JSON serialization tool | JSON manual serialization | writing dart model classes according to JSON | online automatic conversion of dart classes according to JSON)
猜你喜欢

"Analysis of 43 cases of MATLAB neural network": Chapter 43 efficient programming skills of neural network -- Discussion Based on the characteristics of the new version of MATLAB r2012b
![[translation] the background project has joined the CNCF incubator](/img/0b/e3d2674b1a1cba3ea398cbcb1a018a.png)
[translation] the background project has joined the CNCF incubator

Linear rectification function relu and its variants in deep learning activation function

Oauth2.0 authentication, login and access "/oauth/token", how to get the value of request header authorization (basictoken)???

Tongda OA homepage portal workbench

Principle and application of database

Practice of traffic recording and playback in vivo

HTB-Devel
![[hcia]no.15 communication between VLANs](/img/59/a467c5920cbccb72040f39f719d701.jpg)
[hcia]no.15 communication between VLANs
![[fluent] listview list (map method description of list set | vertical list | horizontal list | code example)](/img/e5/c01f760b07b495f5b048ea367e0c21.gif)
[fluent] listview list (map method description of list set | vertical list | horizontal list | code example)
随机推荐
GBase 8c系统表-pg_amproc
[translation] the background project has joined the CNCF incubator
awk从入门到入土(1)awk初次会面
C语言中左值和右值的区别
2022-2028 global splicing display industry research and trend analysis report
【ROS进阶篇】第六讲 ROS中的录制与回放(rosbag)
GBase 8c 函数/存储过程定义
[fluent] JSON model conversion (JSON serialization tool | JSON manual serialization | writing dart model classes according to JSON | online automatic conversion of dart classes according to JSON)
Codeforces Round #418 (Div. 2) D. An overnight dance in discotheque
Gbase 8C system table PG_ constraint
A2L file parsing based on CAN bus (2)
【翻译】Flux安全。通过模糊处理获得更多信心
sql server 查询指定表的表结构
awk从入门到入土(0)awk概述
Awk from getting started to getting into the ground (3) the built-in functions printf and print of awk realize formatted printing
random shuffle注意
Gbase 8C system table PG_ conversion
SQL statement
Check log4j problems using stain analysis
GBase 8c系统表pg_database