当前位置:网站首页>当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>]
边栏推荐
- Hcip137-147 title + analysis
- Why choose a frame? What frame to choose
- Can netstat still play like this?
- Tongda OA homepage portal workbench
- Face recognition 6-face_ recognition_ Py based on OpenCV, face detection and real-time tracking using Haar cascade and Dlib Library
- 左值右指解释的比较好的
- easyExcel
- HTB-Devel
- random shuffle注意
- Awk from getting started to being buried (2) understand the built-in variables and the use of variables in awk
猜你喜欢
HTB-Devel
【翻译】具有集中控制平面的现代应用负载平衡
Basic operation of binary tree (C language version)
What does "where 1=1" mean
The use of Flink CDC mongodb and the implementation of Flink SQL parsing complex nested JSON data in monggo
Can netstat still play like this?
Classes and objects - initialization and cleanup of objects - constructor call rules
oauth2.0鉴权,登录访问 “/oauth/token”,请求头Authorization(basicToken)如何取值???
Tongda OA homepage portal workbench
Check log4j problems using stain analysis
随机推荐
Pytorch convolution network regularization dropblock
COM and cn
UDP receive queue and multiple initialization test
[shutter] setup of shutter development environment (supplement the latest information | the latest installation tutorial on August 25, 2021)
Machine learning process and method
Awk from entry to burial (1) awk first meeting
Check log4j problems using stain analysis
Gbase 8C system table PG_ attribute
Kubernetes family container housekeeper pod online Q & A?
Apple releases MacOS 11.6.4 update: mainly security fixes
GBase 8c系统表-pg_amproc
Monitoring and management of JVM
为什么会选择框架?选择什么样的框架
2022-2028 global splicing display industry research and trend analysis report
GBase 8c系统表-pg_auth_members
SQL statement
xiaodi-笔记
My creation anniversary
[shutter] bottom navigation bar page frame (bottomnavigationbar bottom navigation bar | pageview sliding page | bottom navigation and sliding page associated operation)
《MATLAB 神经网络43个案例分析》:第43章 神经网络高效编程技巧——基于MATLAB R2012b新版本特性的探讨