当前位置:网站首页>当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>]
边栏推荐
- GBase 8c 触发器(一)
- "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
- 【ROS进阶篇】第六讲 ROS中的录制与回放(rosbag)
- Practice of traffic recording and playback in vivo
- where 1=1 是什么意思
- GBase 8c系统表-pg_amproc
- awk从入门到入土(1)awk初次会面
- Packing and unpacking of JS
- sql server 查詢指定錶的錶結構
- Gbase 8C function / stored procedure definition
猜你喜欢
怎么将yolov5中的PANet层改为BiFPN
Classes and objects - initialization and cleanup of objects - constructor call rules
Can netstat still play like this?
Error when installing MySQL in Linux: starting mysql The server quit without updating PID file ([FAILED]al/mysql/data/l.pid
The Linux server needs to install the agent software EPS (agent) database
搭建私有云盘 cloudreve
[flutter] example of asynchronous programming code between future and futurebuilder (futurebuilder constructor setting | handling flutter Chinese garbled | complete code example)
【ROS进阶篇】第六讲 ROS中的录制与回放(rosbag)
Check log4j problems using stain analysis
基于线程池的生产者消费者模型(含阻塞队列)
随机推荐
GBase 8c 创建用户/角色 示例二
基于线程池的生产者消费者模型(含阻塞队列)
A2L file parsing based on CAN bus (2)
awk从入门到入土(2)认识awk内置变量和变量的使用
Oauth2.0 authentication, login and access "/oauth/token", how to get the value of request header authorization (basictoken)???
Awk from introduction to earth (0) overview of awk
Gbase 8C trigger (II)
The Linux server needs to install the agent software EPS (agent) database
Pytorch convolution network regularization dropblock
Gbase 8C system table PG_ conversion
疫情当头,作为Leader如何进行代码版本和需求开发管控?| 社区征文
5. File operation
简单理解svg
awk从入门到入土(0)awk概述
Return a tree structure data
Gbase 8C trigger (I)
[shutter] setup of shutter development environment (supplement the latest information | the latest installation tutorial on August 25, 2021)
Principle and application of database
Thread safe singleton mode
Producer consumer model based on thread pool (including blocking queue)