当前位置:网站首页>当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>]
边栏推荐
- Current situation and future of Web3 in various countries
- sql server 查詢指定錶的錶結構
- Apple releases MacOS 11.6.4 update: mainly security fixes
- Restcloud ETL cross database data aggregation operation
- Create + register sub apps_ Define routes, global routes and sub routes
- Gbase 8C system table PG_ collation
- 【 tutoriel】 Chrome ferme les cors et les messages de la politique inter - domaines et apporte des cookies à travers les domaines
- 【Flutter】shared_ Preferences local storage (introduction | install the shared_preferences plug-in | use the shared_preferences process)
- [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)
- Why choose a frame? What frame to choose
猜你喜欢

定了,就选它

HW initial preparation

random shuffle注意

Random shuffle note

Restcloud ETL cross database data aggregation operation
![[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)

xiaodi-笔记

Your family must be very poor if you fight like this!

Error invalid bound statement (not found): com ruoyi. stock. mapper. StockDetailMapper. XXXX solution

The data in servlet is transferred to JSP page, and the problem cannot be displayed using El expression ${}
随机推荐
[advanced ROS] Lesson 6 recording and playback in ROS (rosbag)
Create + register sub apps_ Define routes, global routes and sub routes
GBase 8c系统表-pg_aggregate
Linear rectification function relu and its variants in deep learning activation function
Can netstat still play like this?
The data in servlet is transferred to JSP page, and the problem cannot be displayed using El expression ${}
QT qcombobox add qccheckbox (drop-down list box insert check box, including source code + comments)
Gbase 8C system table PG_ aggregate
Javescript 0.1 + 0.2 = = 0.3 problem
Cvpr2022 remove rain and fog
[fluent] listview list (map method description of list set | vertical list | horizontal list | code example)
Machine learning process and method
Classes and objects - initialization and cleanup of objects - constructor call rules
Wechat - developed by wechat official account Net core access
5. File operation
[tutorial] chrome turns off cross domain policies CORS and samesite, and brings cookies across domains
Kubernetes cluster log and efk architecture log scheme
定了,就选它
Tongda OA V12 process center
UDP receive queue and multiple initialization test