当前位置:网站首页>当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>]
边栏推荐
- A2L file parsing based on CAN bus (2)
- 定了,就选它
- Restcloud ETL cross database data aggregation operation
- Gbase 8C create user / role example 2
- Detailed analysis of micro service component sentinel (hystrix)
- Add MDF database file to SQL Server database, and the error is reported
- Classes and objects - initialization and cleanup of objects - constructor call rules
- Producer consumer model based on thread pool (including blocking queue)
- awk从入门到入土(0)awk概述
- The sandbox explains its vision for the meta universe platform
猜你喜欢

xiaodi-笔记

Deep learning: multi-layer perceptron and XOR problem (pytoch Implementation)
![Error when installing MySQL in Linux: starting mysql The server quit without updating PID file ([FAILED]al/mysql/data/l.pid](/img/32/25771baad1ed06c5a592087df748f1.jpg)
Error when installing MySQL in Linux: starting mysql The server quit without updating PID file ([FAILED]al/mysql/data/l.pid

【翻译】具有集中控制平面的现代应用负载平衡

Classes and objects - initialization and cleanup of objects - constructor call rules

Add MDF database file to SQL Server database, and the error is reported

random shuffle注意

内存池(内核角度理解new开辟空间的过程)

搭建私有云盘 cloudreve

【Flutter】shared_ Preferences local storage (introduction | install the shared_preferences plug-in | use the shared_preferences process)
随机推荐
How to change the panet layer in yolov5 to bifpn
Oauth2.0 authentication, login and access "/oauth/token", how to get the value of request header authorization (basictoken)???
Random shuffle note
COM and cn
[flutter] example of asynchronous programming code between future and futurebuilder (futurebuilder constructor setting | handling flutter Chinese garbled | complete code example)
awk从入门到入土(0)awk概述
Hcip137-147 title + analysis
Gbase 8C system table PG_ cast
[fluent] future asynchronous programming (introduction | then method | exception capture | async, await keywords | whencomplete method | timeout method)
Tongda OA homepage portal workbench
Basic operation of binary tree (C language version)
【教程】chrome关闭跨域策略cors、samesite,跨域带上cookie
HTB-Devel
Interview stereotyped version
[hcia]no.15 communication between VLANs
MUX VLAN Foundation
Strategy application of Dameng database
Gbase 8C system table PG_ am
Build a private cloud disk cloudrev
簡單理解svg